Thread: Bookmarks
View Single Post
 
Old 06-27-2015, 02:52 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could try something based on:
Code:
Sub UpdateBookMark()
Dim BmkNm As String, NewTxt As String, BmkRng As Range, vUpdType As Variant, Tbl As Table
BmkNm = InputBox("Bookmark Name")
vUpdType = InputBox("Bookmark Update Kind" & vbCr & _
          "1. Predefined Text" & vbCr & _
          "2. A Table & Predefined Text" & vbCr & _
          "3. Variable Text")
With ActiveDocument
  If .Bookmarks.Exists(BmkNm) Then
    Set BmkRng = .Bookmarks(BmkNm).Range
    With BmkRng
      Select Case vUpdType
      Case 1
        .Text = "Predefined Text"
      Case 2
        .Delete
        .InsertBefore vbCr & vbCr
        Set Tbl = .Tables.Add(Range:=.Characters.Last, Numrows:=5, NumColumns:=5)
        With Tbl
          'do stuff with the table
        End With
        .Start = Tbl.Range.Start - 1
        .Characters.First.InsertBefore "Predefined Start Text"
        .End = Tbl.Range.End + 1
        .Characters.Last.InsertAfter "Predefined End Text"
      Case 3
        .Text = InputBox("New Bookmark Text")
      Case Else
        GoTo ErrExit
      End Select
    End With
    .Bookmarks.Add BmkNm, BmkRng
  Else
    MsgBox "Bookmark: " & BmkNm & " not found."
  End If
End With
ErrExit:
Set BmkRng = Nothing: Set Tbl = Nothing
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote