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:
  1. Sub style_tag()
  2.   Selection.Find.ClearFormatting
  3.     Selection.Find.Style = ActiveDocument.Styles("H1")
  4.     Selection.Find.Replacement.ClearFormatting
  5.     With Selection.Find
  6.         .Text = ""
  7.         .Replacement.Text = "^&"
  8.         .Replacement.Font.Color = wdColorBlue
  9.         .Forward = True
  10.         .Wrap = wdFindContinue
  11.         .Format = True
  12.         .MatchCase = False
  13.         .MatchWholeWord = False
  14.         .MatchWildcards = False
  15.         .MatchSoundsLike = False
  16.         .MatchAllWordForms = False
  17.     End With
  18.     Selection.Find.Execute Replace:=wdReplaceAll
  19.     Selection.EscapeKey
  20. 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?