Insert User Input Data

A

Alan Pullman

While I have done a bit of VBA in Excel and Access, I am now trying t
do a job with Word.

I have a standard form that requires user input in a form. I hav
looked at using FILLIN, but I need to retrieve some of the user inpu
data for a second form (in a separate Word document)which may or ma
not have to be filled out.

I have created a new template with an autnew macro. The template ha
enclosing bookmarks, and I insert the user text into the bookmark usin
something like this:

Dim bmrange As Range
Set bmrange = ActiveDocument.Bookmarks("bkmark1").Range
bmrange.Text = "Name"
ActiveDocument.Bookmarks.Add "bkmark1", bmr

This works ok and I can retrieve the data for the second (optional
form using this:

bmtext = ActiveDocument.Bookmarks("bkmark1").Range.Text

The questions I have are:
1. Is this the best approach?
2. As I use InputBox to get my data from the operator, what do I d
about getting 2 or 3 line street addresses. Do I have to have an inpu
box for each address line?

I hope you can help
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Alan,

If you define the bookmark so that it encloses a space and looks like []
when you have the bookmarks visible in the document and if you use

ActiveDocument.Bookmarks("bkmark1").Range.InsertBefore "Name"

that text will be inserted inside the bookmark as [ Name] so that you can
refer to it.

In the second document, you could use { INCLUDETEXT } fields that reference
the bookmarks in the first document. Alternatively, you could use
System.PrivateProfileString to write the information to an ini file from
where it can be retrieved using that same function.

In addition, you probably should consider a userform rather than Fillin
fields.

See the article “How to create a Userform” at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm


--
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

Similar Threads


Top