I have to write a VBA macro to identify and delete style types that have been applied to the bullet symbol in a bulleted list.
In the below document.xml part, we have a bullet with style type 'italic' applied.
<w w:rsidR="000450E5" w:rsidRPr="00A4560A" w:rsidRDefault="000450E5" w:rsidP="0009336F">
<w:pPr>
<w:pStyle w:val="ListBullet"/>
<w:rPr>
<w:i/>
<w:lang w:val="es-ES"/>
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="00A4560A">
<w:rPr>
<w:lang w:val="es-ES"/>
</w:rPr>
<w:t xml:space="preserve">el marco legislativo y </w:t>
</w:r>
in above example, <w:i/>
is the italic style.
So the document.cxml code associated with the 'italic' style type added bullet is like :
<tps:liFormat><tps:style type="italic">—<tps:t/></tps:style></tps:liFormat>
What I need to do is, create a VB macro to remove those tags applied for bullets from the document.
Below is my code. I was just able to identify the bullet lists. I am still unable to find a way to check the style type applied.
Public Sub main()
Dim objDocument As Word.Document
Dim objParagraph As Word.Paragraph
Set objDocument = Word.ActiveDocument
For Each objParagraph In objDocument.Paragraphs
If objParagraph.Range.ListFormat.ListType = WdListType.wdListBullet Then
If objParagraph.Range.ListFormat.StyleType = 'Italic' then //Is there something like thid?
//remove to set to normal
End If
End If
Next objParagraph
End Sub
Could anybody help me to identify and remove the style type added to the bullet.. Thank you in advance.
tps
. Is this Word Open XML from a standard docx file? IF not, what is it? w:i is not the name of any style - it's a direct formatting command and appears to have been applied by a user to the document, possibly via the Bullets dialog box. The name of the style is ListBullet and its definition would be found in the Styles.xml part of the docx zip file - you should inspect that. StyleType refers to whether a style is a character, paragraph, linked, etc. Style and is not relevant for this. – Cindy Meister