Discussion:
Hide/show bookmark through macro
(too old to reply)
Deejay
2007-10-17 22:32:03 UTC
Permalink
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
2007-10-17 23:45:16 UTC
Permalink
On Wed, 17 Oct 2007 15:32:03 -0700, Deejay
Post by 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.
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
2007-10-18 20:27:01 UTC
Permalink
Thank you so much. And just one more question: how would I change the text
within the bookmark?
Post by Jay Freedman
On Wed, 17 Oct 2007 15:32:03 -0700, Deejay
Post by 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.
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.
Jay Freedman
2007-10-18 21:13:07 UTC
Permalink
ActiveDocument.Bookmarks("MyBookmarkName").Range.Text = "some text"
Post by Deejay
Thank you so much. And just one more question: how would I change the
text within the bookmark?
Post by Jay Freedman
On Wed, 17 Oct 2007 15:32:03 -0700, Deejay
Post by 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.
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.
Jean-Guy Marcil
2007-10-18 21:35:42 UTC
Permalink
Post by Jay Freedman
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
***@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
aravind
2007-11-15 11:54:02 UTC
Permalink
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
Post by Jean-Guy Marcil
Post by Jay Freedman
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
'_______________________________________
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
Word MVP site: http://www.word.mvps.org
Jean-Guy Marcil
2007-11-15 21:20:32 UTC
Permalink
Post by 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...
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
***@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Johann Spurzheim
2010-10-16 11:53:27 UTC
Permalink
This addin for Word will create a toggle button on the page for hiding/showing any selected part of a document. Lots more features. See http://www.moreaddin.com
Post by 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.
Post by Jay Freedman
On Wed, 17 Oct 2007 15:32:03 -0700, Deejay
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.
Post by Deejay
Thank you so much. And just one more question: how would I change the text
within the bookmark?
Post by Jay Freedman
ActiveDocument.Bookmarks("MyBookmarkName").Range.Text = "some text"
Post by Jean-Guy Marcil
DeeJay, keep in mind that this will delete the bookmark.
If you need it for further processing, use something like this to restore
'_______________________________________
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
Word MVP site: http://www.word.mvps.org
Post by 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
Post by Jean-Guy Marcil
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
Word MVP site: http://www.word.mvps.org
Submitted via EggHeadCafe - Software Developer Portal of Choice
Flat file Database with LINQ and ASP.NET jQuery Page Methods
http://www.eggheadcafe.com/tutorials/aspnet/c8c43191-c3a3-4c61-801a-2433a701f4f6/flat-file-database-with-linq-and-aspnet-jquery-page-methods.aspx
Continue reading on narkive:
Loading...