Can bookmark survive deletion of text?

L

Larry

Is it possible to delete all the text in a document without deleting a
hidden bookmark in that document?

Larry
 
L

Larry

I know it sounded like a stupid question. How can the bookmark survive
if the text in which it existed has been deleted? But I thought there
might be a kind of bookmark (like the bookmark that pertains to a page,
i.e., it's not based in text) that might survive.

Larry
 
D

Doug Robbins - Word MVP

Hi Larry,

Use:

Dim myrange As Range
Set myrange = ActiveDocument.Bookmarks("Test").Range
myrange.Text = ""
ActiveDocument.Bookmarks.Add "Test", myrange

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
L

Larry

Thanks, Doug. Instead of deleting all the text while preserving the
bookmark, it deletes all the text including the bookmark, then recreates
the bookmark in the remaining single paragraph mark. I think that's as
close as it's possible to get to what I'm looking for. (It's too
complicated to explain what I needed this for.)

Larry
 
D

Doug Robbins - Word MVP

Hi Larry,

You could change

myrange.Text = ""

to

myrange.Text = "something else"

if you wanted the bookmark to contain something else at the end of the
exercise

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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