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 / October 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nicolas Tostin - 18 Oct 2005 20:20 GMT
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
Jay Freedman - 18 Oct 2005 20:28 GMT
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.

See http://word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm for a
code sample.

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

> Hi,
> I got a little problem.
[quoted text clipped - 23 lines]
>
> Nicolas
Nicolas Tostin - 19 Oct 2005 02:01 GMT
> 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
Jean-Guy Marcil - 18 Oct 2005 21:18 GMT
Nicolas Tostin was telling us:
Nicolas Tostin nous racontait que :

> Hi,
> I got a little problem.
[quoted text clipped - 23 lines]
>
> 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!

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.