![]() |
#9
|
|||
|
|||
![]()
When you next ask a question please include as much detail as possible. It is very hard to help someone when they haven't provided vital details, i.e. "I have a document with inserted bookmarks" and "The document is created by a VB6 program"
The attached screenshot shows the difference between a collapsed and enclosing bookmark, and how to show bookmarks in your document. If you have no control over the document and you know that the code is never more than 4 characters you can edit your code as follows: Code:
Sub TestBookmark() Dim rng As Range Dim code As String If ActiveDocument.Bookmarks.Exists("code") Then Set rng = ActiveDocument.Bookmarks("code").Range If rng.Start = rng.End Then rng.MoveEnd wdCharacter, 4 code = rng.Text Debug.Print code Else code = rng.Text Debug.Print code End If Else MsgBox "This bookmark doesn't exist" & vbCr & "code" End If End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Jennifer Murphy | Word | 4 | 02-20-2023 06:36 PM |
Changing Caption Position on Whole Document at once | Alexandarale | Word Tables | 1 | 11-15-2020 06:56 PM |
![]() |
gasparik | Word VBA | 1 | 05-11-2020 05:41 AM |
Starting a document, returning to last position | glennnall | Word | 0 | 10-08-2017 10:09 AM |
![]() |
tinfanide | Excel Programming | 3 | 02-27-2012 03:24 PM |