Hi,
I was just wondering if there is a way to store a valur that turns up within
Selection.Find.Text
Consider the following code
VB Code:
Sub style_tag() Selection.Find.ClearFormatting Selection.Find.Style = ActiveDocument.Styles("H1") Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "" .Replacement.Text = "^&" .Replacement.Font.Color = wdColorBlue .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll Selection.EscapeKey End Sub
Now the above code finds where the style name H1 has been applied and highlights the selected text to blue.
Is there a way in which i can store the resultant text in a variable?
Example: if the style h1 is applied to a word "Chapter 1" then this code searches h1 style and highlights "Chapter 1" to blue. Is there a way in which i can store the highlighted text in a variable?




Reply With Quote