Bookmark Reference Not Populating

M

Melanie Strom

I have a userform that contains bookmarks and references to bookmark text.
After filling out the information in the form and populating the document
with the data, the references to the bookmark text do not populate. I have
tried updating the field, but that is not working. I have another document
where I have bookmark references and it works just fine. I've tried
recreating the document without any success. Any other ideas?
 
C

Chip Orange

It sounds like the references to the bookmarks may have the incorrect
bookmark name?

Chip
 
M

Melanie Strom

The bookmark name is correct; I chose from the list of bookmarks. After a
little more trial and error, I have been able to get most of the bookmarks to
appear in the cross-references. For the original bookmark, I created a
space, selected it and put the bookmark there. That worked for all except
one. This bookmark is created from a drop-down selection in the userform.
Would that have anything to do with it?

Is there another way I can get the bookmark text to appear in more than one
place in the document?
 
G

Greg Maxey

Melanie,

First, while documents main contain bookmarks userforms don't.

Let's say you have a UserForm that contains a text control txtClientName.
You have a document that has a bookmark in the document "ClientName" and
then you have dispersed one or more REF fields {REF ClientName}in the
document where you want the client's name populated.

I suspect that you are inserting the text (client name) entered in the
UserForm "at" vise "in" the bookmark in the document. When your display
bookmarks in the document is the text you entered in the UserForm "within"
the grey brackets marking the bookmark?

In your userform try a command button code like this

Dim oRng as Word.Range
Set oRng = ActiveDocument.Bookmarks("ClientName").Range
oRng.Text = Me.txtClientName"
ActiveDocument.Bookmarks.Add "ClientName", oRng
ActiveDocument.Fields.Update
Unload Me
 
M

Melanie Strom

Thank you for your help thus far. VBA isn't my specialty, so please bear
with me. Your assumptions are correct. I added the code you suggested, but
the macro gets stuck at:

oRng.Text = Me.txtClientName

It says "Method or data member not found" and highlights ".txtClientName".
I've tried different ways to fix it, to no avail.
 
C

Chip Orange

No, you're on the right path using bookmarks and cross reference fields.

If you create it from a user form, then is this done dynamicly? Maybe you
need to update the reference field after you create the bookmark?

You can just choose to update all fields, or find the correct field and just
update it (it's pretty hard to find the correct field in VBA; you have to
loop through all of them, looking at their contents to find the one that's
referencing the bookmark you just created).

hth,

Chip
 

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