View Single Post
 
Old 03-31-2014, 06:26 AM
XmisterIS XmisterIS is offline Windows 7 64bit Office 2007
Novice
 
Join Date: Sep 2013
Posts: 12
XmisterIS is on a distinguished road
Default How to parse bold sections of a paragraph?

I am writing a piece of code which parses the paragraphs of a document and uploads relevant bits to a server.

Consider a document in which three paragraphs exist, with Normal style.

The first para contains no additional formatting.
The second para is entirely bolded.
One word only within the third para is bolded.

Now, consider the following macro:

Code:
Public Sub paratest()
    Dim i As Integer
    
    For i = 1 To ActiveDocument.Paragraphs.Count
        With ActiveDocument.Paragraphs.Item(i)
            Debug.Print .Range.Text
            Debug.Print "Bold: ".Range.Bold
        End With
    Next
End Sub
This gives an output like:

Quote:
This is the first paragraph
Bold: 0

This is the second paragraph
Bold: -1

This is the third paragraph
Bold: 9999999
In fact, in the 3rd para, the word "third" is bolded, all the rest are not.

How can I programmatically discover which parts (text runs?) within each para have had additional formatting applied?
Reply With Quote