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: 5794777"] Lisa, This string started out with you having several templates and you are going to being inserting one or more templates into another template. What are these "templates?" Is each identical to the sample text you provided earlier? Where does the job number come from? Is it inputted by the user? Is the number already in the "templates" as you add them to the other template? Is it put in afterwards. I think I, or several others, that read these groups might be able to assist you with an answer if you can provide a clear decription of the problem. As it stands, I see a large document that consists of a bunch of single cell tables that contain a name. Then a bunch of data fields. Finally a string of text "DMIJobNumber#" You want to know if there is a bookmark adjacent to that text if not you want to add one at that piont. Here is some rather crude code that does that: 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 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