Deleting Bookmarks Part II

R

Ron

Below is a snipet of the code I use to delete two bookmarks that I am
populating from Access. I've traced the code and everything is being executed
properly, but spaces and a blank line are appearing in the bookmark locations
when the Word document is constructed. Is there something else I have to do?

MyCheck = IsNull(rs!OrganizationName)
If MyCheck = True Then
objWord.ActiveDocument.Bookmarks("Organization").Delete
Else
.Item("Organization").Range.Text = rs!OrganizationName
End If
MyCheck = IsNull(rs!Title)
If MyCheck = True Then
objWord.ActiveDocument.Bookmarks("Title").Delete
Else
.Item("Title").Range.Text = rs!Title
End If
.Item("City").Range.Text = rs!City
.Item("FirstName").Range.Text = rs!FirstName
.Item("LastName").Range.Text = rs!LastName
 
D

Dave Lett

Hi Ron,

All you're doing is deleting the bookmark. If you want to remove the
_contents_ of the bookmark, then you need to delete its range.

objWord.ActiveDocument.Bookmarks("Organization").Range.Delete

This will delete _anything_ within the range of the bookmark.

HTH,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top