Userform InsertBefore Bookmark Problem

R

ronneilan

I have set up a userform which posts content to bookmarks in a
document using the InsertBefore method and then into Ref fields I have
placed through the document to pick up the content of the bookmarks.

I did this based on a MVP article I found which recommended I create
the bookmark with a space i.e. [ ] rather than | .The space method
creates a problem throughout my document of having an extra space
after the word brought into the document from the form into the
bookmark. If I do it the other way my Refs don't pick up the text
which is dropped into the document as it is inserted before the
bookmark not actually in it.

Can any of you smart people help me out with a technique to get the
text from the userform into the bookmark so that there isn't any space
and the into the ref entries. Please.
 
D

Doug Robbins - Word MVP

An alternative to the use of a bookmark is to create document variables to
hold the data from the controls on the userform and then use DOCVARIABLE
fields in the document wherever you want the information to appear.

To create the document variables, you would use the following code in the
user form in place of that which inserts the information into the bookmarks

With ActiveDocument
.Variables("varname1").Value = [controlname1].text
etc.
.Range.Fields.Update
End With

The corresponding document variable field for the above would be {
DOCVARIABLE varname1 } You can have as many instances of the one document
variable field in the document as you wish.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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