How to assign a value to a bookmark for the second time ?  
Author Message
Hohoho





PostPosted: Sun Dec 21 15:39:17 CST 2003 Top

MS Word VBA >> How to assign a value to a bookmark for the second time ?

Is it possible to assign the value of a bookmark more than one time?

I've seen that Word deletes the bookmark when it is assigned a value by

objword.ActiveDocument.Bookmarks(NameOfBookmark).Select
objword.Selection.Text = NewValue

That's why I can't use this for the second time because the document doesn't
have the bookmarks anymore.

Oscar

Word92  
 
 
Jezebel





PostPosted: Sun Dec 21 15:39:17 CST 2003 Top

MS Word VBA >> How to assign a value to a bookmark for the second time ? There's nothing to stop you re-adding the bookmark --

objword.ActiveDocument.Bookmarks(NameOfBookmark).Select
objword.Selection.Text = NewValue
objword.ActiveDocument.Bookmarks.Add Name:=NameOfBookMark,
Range:=objword.Selection





> Is it possible to assign the value of a bookmark more than one time?
>
> I've seen that Word deletes the bookmark when it is assigned a value by
>
> objword.ActiveDocument.Bookmarks(NameOfBookmark).Select
> objword.Selection.Text = NewValue
>
> That's why I can't use this for the second time because the document
doesn't
> have the bookmarks anymore.
>
> Oscar
>
>


 
 
Doug





PostPosted: Sun Dec 21 16:02:56 CST 2003 Top

MS Word VBA >> How to assign a value to a bookmark for the second time ? Hi Oscar,

See the article ?Inserting text at a bookmark without deleting the bookmark?
at:

http://www.mvps.org/word/FAQs/MacrosVBA/InsertingTextAtBookmark.htm

Instead of using bookmarks, you can use { DOCVARIABLE "varname" } fields and
then use

ActiveDocument.Variables("varname").Value = NewValue
ActiveDocument.Fields.Update

as many times as you wish.

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


> Is it possible to assign the value of a bookmark more than one time?
>
> I've seen that Word deletes the bookmark when it is assigned a value by
>
> objword.ActiveDocument.Bookmarks(NameOfBookmark).Select
> objword.Selection.Text = NewValue
>
> That's why I can't use this for the second time because the document
doesn't
> have the bookmarks anymore.
>
> Oscar
>
>


 
 
Jonathan





PostPosted: Sun Dec 21 15:29:27 CST 2003 Top

MS Word VBA >> How to assign a value to a bookmark for the second time ?


> Is it possible to assign the value of a bookmark more than one time?
>
> I've seen that Word deletes the bookmark when it is assigned a value by
>
> objword.ActiveDocument.Bookmarks(NameOfBookmark).Select
> objword.Selection.Text = NewValue
>
> That's why I can't use this for the second time because the document
doesn't
> have the bookmarks anymore.

Hi Oscar,

You need to recreate the bookmark. Take a look at this article

Inserting text at a bookmark without deleting the bookmark
http://www.mvps.org/word/FAQs/MacrosVBA/InsertingTextAtBookmark.htm

--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup

 
 
Oscar





PostPosted: Sun Dec 21 17:10:03 CST 2003 Top

MS Word VBA >> How to assign a value to a bookmark for the second time ? thank you all for your help,

nice methods, especially that of variable adressing.

regards,
Oscar





> Is it possible to assign the value of a bookmark more than one time?
>
> I've seen that Word deletes the bookmark when it is assigned a value by
>
> objword.ActiveDocument.Bookmarks(NameOfBookmark).Select
> objword.Selection.Text = NewValue
>
> That's why I can't use this for the second time because the document
doesn't
> have the bookmarks anymore.
>
> Oscar
>
>