![]() |
|
#12
|
|||
|
|||
|
This example displays the numbers for all bookmarks in your document as a msgBox. Since it appears your numbers vary in size, I'm extending the range as long as their are numbers in it. In the code below, you can see the line where your bookmark value from the document is being stored as the var, bookmarkValue.
It was being stored in the previous example as "code", so as Italophile mentioned, you are already storing it as a variable. Next question for you - What are you going to do with the variable once you have it? Posting a sample Word document (not screen shots) with the actual bookmarks you're trying to work with, and details about your end goal would be helpful. This is like a mystery that we're learning a little more with each iteration ![]() Code:
Sub bookmarkValues()
Dim rng As Range
Dim bm As Bookmark
Dim rng_expanded As Range
Dim bookmarkValue As String
For Each bm In ActiveDocument.Bookmarks
Set rng = bm.Range
If rng.Start = rng.End Then
Set rng_expanded = rng
rng_expanded.MoveEndWhile cset:="0123456789"
' Store bookmark document text as a variable
bookmarkValue = rng_expanded.Text
Call MsgBox(prompt:=("Bookmark value: " & bookmarkValue), buttons:=vbOKOnly)
End If
Next bm
End Sub
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Can I make Word remember the window size and position for each document?
|
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 |
Copy selected text from one document and paste to new document in same position on the page
|
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 |
VBA: how can I know the position on a document?
|
tinfanide | Excel Programming | 3 | 02-27-2012 03:24 PM |