Andreas Hermle
asked on
Bookmark instances of user defined style
Dear Experts:
Below macro is supposed to bookmark paragraphs a certain way where a user-defined style (user-style) has been applied.
The code does not find any paragraph where the user-defined style (user-style) has been applied. What is wrong with this code?
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
Below macro is supposed to bookmark paragraphs a certain way where a user-defined style (user-style) has been applied.
The code does not find any paragraph where the user-defined style (user-style) has been applied. What is wrong with this code?
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
Sub BookmarkInstancesOfStyle
Dim strLanguages As Variant
Dim i As Long
Dim frange As Range
i = 0
Selection.HomeKey wdStory
Selection.Find.Style = ActiveDocument.Styles("user-style")
strLanguages = Array("de", "en", "es", "fr", "it")
With Selection.Find
Do While .Execute(FindText:="", Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True
Set frange = Selection.Range
ActiveDocument.Bookmarks.Add "MainTOC_" & strLanguages(i), frange
i = i + 1
Selection.Collapse wdCollapseEnd
Loop
End With
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
great, your new code works for me just fine. Thank you so much for your professional help. Have a nice weekend. Regards, Andreas