View Single Post
 
Old 07-08-2013, 01:29 AM
Kreol2013 Kreol2013 is offline Windows 7 32bit Office 2013
Novice
 
Join Date: Apr 2013
Posts: 8
Kreol2013 is on a distinguished road
Question An array of words from a document knowing the font style

Welcome.
Sir, please tell me how to get an array of words and their initial positions in the document with only the font style?
That is, we have a document with as far as styles.
we highlight one of the words, and we want to get all the words that have the same style.
Trying to describe the right.
Code:
Sub Style_work()
Dim S As String
    S = Selection.Text
    Dim style_1 As Word.Style
    style_1 = Selection.style
    If VBA.Len(S) <= 0 Then Exit Sub
    With ActiveDocument.Find (ActiveDocument=Selection)
        .style = style1
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    ActiveDocument.Find.Execute
    
End Sub
Thank you for your help.
Anton
Reply With Quote