Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word VBA Beginners
Adding bookmarks in VBA in a specific place
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Greg Maxey, post: 5794782"] Lisa, With the code I provide last time the range where the bookmark is inserted has been collapsed just after the #. I see that you have a colon after the # (maybe I missed that before). To create a content bookmark, you will need to move the end of the range out a certain number of characters. These characters should probably be included in your templates. Something like: Sub Test() Dim oRng As Word.Range Dim oBM As Word.Bookmark Dim i As Long Set oRng = ActiveDocument.Range For i = 1 To ActiveDocument.Tables.Count oRng.Start = ActiveDocument.Tables(i).Range.End With oRng.Find .Text = "DMIJobNumber#:" .Execute If .Found = True Then oRng.Collapse wdCollapseEnd oRng.MoveEnd wdCharacter, 4 If oRng.Bookmarks.Count > 0 Then MsgBox oRng.Bookmarks(1).Name Else oRng.Bookmarks.Add "Somename" & i, oRng End If End If End With Next i End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word VBA Beginners
Adding bookmarks in VBA in a specific place
Top