Problem to insert same datas to different places (bookmarks & REF)

N

Nicolas Tostin

Hi,
I got a little problem.
I try this example http://www.computorcompanion.com/LPMArticle.asp?ID=224
which is exactly what I need : inserting my client name in various place in
a Word Document (I'm using Word 2000)

I try something very simple :
- add a "clientName" bookmark in my doc
- type text and add a { REF clientName } reference to get the value of my
bookmark
- I made this very little script :
Sub test()
ActiveDocument.Bookmarks("clientName").Range.Text = "John Doe"
Selection.WholeStory
Selection.Fields.Update
Selection.Fields.ToggleShowCodes
End Sub

Then I got my bookmark point updated as I expected but the REF point is not.

What am I doing wrong ?

Thanks a lot for your help

Nicolas
 
J

Jean-Guy Marcil

Nicolas Tostin was telling us:
Nicolas Tostin nous racontait que :
Hi,
I got a little problem.
I try this example
http://www.computorcompanion.com/LPMArticle.asp?ID=224 which is
exactly what I need : inserting my client name in various place in a
Word Document (I'm using Word 2000)

I try something very simple :
- add a "clientName" bookmark in my doc
- type text and add a { REF clientName } reference to get the value
of my bookmark
- I made this very little script :
Sub test()
ActiveDocument.Bookmarks("clientName").Range.Text = "John Doe"
Selection.WholeStory
Selection.Fields.Update
Selection.Fields.ToggleShowCodes
End Sub

Then I got my bookmark point updated as I expected but the REF point
is not.

What am I doing wrong ?

Thanks a lot for your help

Nicolas

En passant, j'ai vu ton message dans le groupe français et je dois admettre
que je ne comprennais pas ton problème.
Ceci étant dit, si tu avais expliqué ta situation aussi bien en français que
tu viens de le faire en anglais, tu aurais eu une réponse satisfaisante très
vite!

Bonne chance!

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

Nicolas Tostin

Inserting text in the bookmark destroys the bookmark itself. Then the REF
has nothing to refer to. Your code needs to re-create the bookmark after
overwriting it.
Hi Jay,
Thanks for your input.
I've had already seen your Word FAQ but I was misunderstanding Word's
behaviour.
Let's explain:
After inserting text (John for ex.) for my bookmark, I get "][John" the
"][" symbol stands for the brackets' bookmark symbol.
So I thought that Word didn't delete my bookmark (it's still display in
bookmark list).
But I stay focused on this idea, and couldn't get it working.
So thanks again, after adding you little script, I get it working
perfectly with my references correctly updated. (Now I get "[John]")

Regards
Nicolas
 

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