Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Hide/show bookmark through macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Deejay - 17 Oct 2007 23:32 GMT
what would i put in to a macro to hide/show a section of text whichi is
bookmarked?

Using xp and w2007.

Many thanks.
Jay Freedman - 18 Oct 2007 00:45 GMT
>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.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
Deejay - 18 Oct 2007 21:27 GMT
Thank you so much. And just one more question: how would I change the text
within the bookmark?

> >what would i put in to a macro to hide/show a section of text whichi is
> >bookmarked?
[quoted text clipped - 15 lines]
> Microsoft Word MVP        FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
Jay Freedman - 18 Oct 2007 22:13 GMT
ActiveDocument.Bookmarks("MyBookmarkName").Range.Text = "some text"

> Thank you so much. And just one more question: how would I change the
> text within the bookmark?
[quoted text clipped - 19 lines]
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
Jean-Guy Marcil - 18 Oct 2007 22:35 GMT
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
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

aravind - 15 Nov 2007 11:54 GMT
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

> Jay Freedman was telling us:
> Jay Freedman nous racontait que :
[quoted text clipped - 17 lines]
> ActiveDocument.Bookmarks.Add strBookMark, rgeBookMark
> '_______________________________________
Jean-Guy Marcil - 15 Nov 2007 21:20 GMT
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?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.