Thread: [Solved] Delete Range After Bookmark?
View Single Post
 
Old 04-05-2013, 05:05 AM
macropod's Avatar
macropod macropod is online now 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

The proper way to update bookmark content is to add the content to the bookmark, not after it. Use code like:
Code:
Sub UpdateBookmark (wdDoc as Document, BmkNm as string, NewTxt as string)
Dim BmkRng as Word.Range
With wdDoc
  If.Bookmarks.Exists(BmkNm) Then
    Set BmkRng =.Bookmarks(BmkNm).Range
    BmkRng.Text = NewTxt
    .Bookmarks.Add BmkNm, BmkRng
  End if
End With
Set BmkRng = Nothing
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote