Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 07-14-2016, 02:28 PM
DougMVP DougMVP is offline How to add a bookmark to text within a header Windows 7 32bit How to add a bookmark to text within a header Office 2010 32bit
Advanced Beginner
 
Join Date: Nov 2013
Posts: 50
DougMVP will become famous soon enough
Default

Use:

Code:
Dim bkmarkname As String
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 5")
With Selection.Find
    Do While .Execute(FindText:="", MatchWildcards:=False, Forward:=True, Wrap:=wdFindStop) = True
        With Selection
            If Instr(.Range.Text, "|") > 0 then
                 bkmarkname = Mid(.Range.Text, InStr(.Range.Text, "|") + 2, InStrRev(.Range.Text, "|") - InStr(.Range.Text, "|") - 2)
                 ActiveDocument.Bookmarks.Add Trim(bkmarkname), .Range
            End If
            .Collapse wdCollapseEnd
        End With
    Loop
End With
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Bookmark, move to bookmark, execute code, repeat raymm3852 Word VBA 10 04-15-2016 06:21 PM
Add a bookmark to the Header using Word VBA ChrisDevrell Word VBA 2 02-06-2015 04:15 PM
Adding field in word in header in a bookmark in table with Excel vba Late Binding Hdr Excel Programming 6 02-11-2013 02:58 AM
How to add a bookmark to text within a header Open header to insert text into bookmark Amapola188 Word VBA 3 07-12-2012 05:16 PM
How to add a bookmark to text within a header Word 2003 - IncludeText Does Not Include Bookmark Text if in a Form Text Control skarden Word 1 12-12-2011 10:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:22 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft