Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
activedocument.Bookmarks("[i]YourBookmark[/i]").Select
Dim oRange As Range
Set oRange = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary) _
.Range.Bookmarks("TEST").Range
oRange.Text = "TEST THIS BOOKMARK"
[COLOR=red]' take out the recreation of the bookmark
'ActiveDocument.Bookmarks.Add Name:="TEST", Range:=oRange[COLOR=red]
Set oRange = Nothing
[COLOR=red] ' run it again with new text
Set oRange = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary) _
.Range.Bookmarks("TEST").Range
oRange.Text = "TEST THIS SECOND BOOKMARK"
Sub CheckForBookmarks()
Dim r As Range
Dim i As Integer
Dim SectionCount As Integer
Dim BookmarkIndexNumber As Integer
Dim strBookmarkName As String
Dim msg As String
Dim var
Dim var2
Dim var3
SectionCount = 1
i = 1
For var = 1 To ActiveDocument.Sections.Count
For var2 = 1 To 3
Set r = ActiveDocument.Sections(SectionCount).Headers(i).Range
If r.Bookmarks.Count > 0 Then
Select Case i
Case 1
BookmarkIndexNumber = 1
For var3 = 1 To r.Bookmarks.Count
msg = msg & r.Bookmarks(BookmarkIndexNumber).Name
BookmarkIndexNumber = BookmarkIndexNumber + 1
Next
MsgBox "Section " & SectionCount & _
" Primary header contains " & _
r.Bookmarks.Count & " bookmark(s)." & _
vbCrLf & "Their name(s) are: " & vbCrLf & _
msg
Case 2
BookmarkIndexNumber = 1
For var3 = 1 To r.Bookmarks.Count
msg = msg & r.Bookmarks(BookmarkIndexNumber).Name
BookmarkIndexNumber = BookmarkIndexNumber + 1
Next
MsgBox "Section " & SectionCount & _
" First Page header contains " & _
r.Bookmarks.Count & " bookmark(s)." & _
vbCrLf & "Their name(s) are: " & vbCrLf & _
msg
Case 3
BookmarkIndexNumber = 1
For var3 = 1 To r.Bookmarks.Count
msg = msg & r.Bookmarks(BookmarkIndexNumber).Name
BookmarkIndexNumber = BookmarkIndexNumber + 1
Next
MsgBox "Section " & SectionCount & _
" Primary header contains " & _
r.Bookmarks.Count & " bookmark(s)." & _
vbCrLf & "Their name(s) are: " & vbCrLf & _
msg
End Select
End If
Set r = Nothing
i = i + 1
Next
SectionCount = SectionCount + 1
i = 1
Next
End Sub