What property to insert user form info

J

Jim Edwards

Hi,
I have looked and not found or understood how to insert data from a user
form to a document. All I want to do is insert the value from a user form
control and insert it into a defined place on a document. I tried with and
without defining a variable. Getting the value from the user form is easy,
trying to figure out if I need a field, bookmark or range on the document is
killing me.
I tried activedocument.bookmark"Example".text and
activedocument.bookmark"Example".value

I can't find a property of a field that even gets close and I don't know how
to define a range in the document except with code.

It's gotta be an easy thing, but I am new to Word VBA .
Thanks, Jim
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Jim,

I favour the use of document variables and {DOCVARIABLE} fields in the
document.

ActiveDocument.Variables("varname").Value = [userformdata]

and in the document

{ DOCVARIABLE "varname" }

You do need to include a Fields.Update in the code however to get the value
displayed in the document.

You can do a similar thing with CustomDocumentProperties and { DOCPROPERTY }
fields, but the user can then delete the property/edit the values while the
only way you can do anything other than display the value of a document
variable is by use of VBA

If you want to use bookmarks, you use

ActiveDocument.Bookmarks("bookmarkname").Range.InsertBefore [userformdata]

If the data is going into a particular cell of a table, you can insert
before the .Range of the cell.

Note that if you define the bookmark so that it contains a single space, the
data will be inserted inside the [bookmark ] so that you can then reference
it by means of a cross reference field to the text of the bookmark.

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
 

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