Hide/show bookmark through macro

D

Deejay

what would i put in to a macro to hide/show a section of text whichi is
bookmarked?

Using xp and w2007.

Many thanks.
 
J

Jay Freedman

what would i put in to a macro to hide/show a section of text whichi is
bookmarked?

Using xp and w2007.

Many thanks.

To hide:

ActiveDocument.Bookmarks("MyBookmarkName").Range.Font.Hidden = True

To show it, use the same line with False on the right of the equal
sign.
 
D

Deejay

Thank you so much. And just one more question: how would I change the text
within the bookmark?
 
J

Jean-Guy Marcil

Jay Freedman was telling us:
Jay Freedman nous racontait que :
ActiveDocument.Bookmarks("MyBookmarkName").Range.Text = "some text"


DeeJay, keep in mind that this will delete the bookmark.

If you need it for further processing, use something like this to restore
the bookmark after changing its content:

'_______________________________________
Const strBookMark As String = "MyBookmarkName"

Dim rgeBookMark As Range

Set rgeBookMark = ActiveDocument.Bookmarks(strBookMark).Range

rgeBookMark.Text = "Some New Text"

ActiveDocument.Bookmarks.Add strBookMark, rgeBookMark
'_______________________________________

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

aravind

sir i wanted to know how to add an existing bookmark at specified position....
the main purpose of this is i am doing a vsto project so i wanted to add,
delete and reorder the book marks so how can i add an existing book mark and
after deletion also i must be able to add those book marks and perform other
things as i told before...

pls can any one help me regarding this
 
J

Jean-Guy Marcil

aravind was telling us:
aravind nous racontait que :
sir i wanted to know how to add an existing bookmark at specified
position.... the main purpose of this is i am doing a vsto project so
i wanted to add, delete and reorder the book marks so how can i add
an existing book mark and after deletion also i must be able to add
those book marks and perform other things as i told before...

Can you clarify exactly what you want to do?

You need to be able to define ranges where the bookmarks will be added. How
will you define those ranges?

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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