Trying to write a macro for Word 2010 that will detect whether a specific style (called "Heading 1,UM H1") is used for any of the text on the current page. Here is my attempt. It doesn't work. What am I doing wrong?
Sub DetectUMH1Style()
' Select current page
ActiveDocument.Bookmarks("\page").Range.Select
' Search for target style
TargetStyle = ActiveDocument.Styles("Heading 1,UM H1")
MsgBox ("Target style name = '" & TargetStyle & "'")
Selection.Find.Style = TargetStyle
Selection.Find.Execute
If Selection.Find.Found = True Then
MsgBox ("At least one instance of target style found")
Else
MsgBox ("No instances of target style found")
End If
End Sub