I think you are going to have to do that manually. Here is why. When you insert text like your example you are insert the text "at" the bookmark. Specifically just after it. Once it is there, there is nothing to define what the "end" range is.
The better way that would give you a mean to later to delete the text is to insert text "in" a bookmark.
Sub ScratchMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Bookmarks("Name2").Range
oRng.Text = "anything"
ActiveDocument.Bookmarks.Add "Name2", oRng
End Sub
You can then delete the text or the text and the bookmark with:
Sub ScratchMacroII()
'A quick macro scratch pad created by Greg Maxey
Dim i As Long
Dim pStr As String
Dim oRng As Word.Range
'Delete text and preserve bookmark
For i = ActiveDocument.Bookmarks.Count To 1 Step -1
Set oRng = ActiveDocument.Bookmarks(i).Range
pStr = ActiveDocument.Bookmarks(i).Name
oRng.Text = ""
ActiveDocument.Bookmarks.Add pStr, oRng
Next i
'delete both
For i = ActiveDocument.Bookmarks.Count To 1 Step -1
ActiveDocument.Bookmarks(i).Range.Delete
Next i
End Sub
|