Creating User Forms - Novice question 
Author Message
 Creating User Forms - Novice question

I have a word table that I want a user to fill in.  However, rather than
type directly into the table, I want them to enter the data via a form (that
looks like one I would normally create in Access).
I can create the form with textboxes and comboboxes but have no idea how to
link these controls on the form to the fields in the table in Word.  I'm
used to creating forms in Access but just cannot get them to work in Word.

Can anyone help please?

Many thanks in advance

Joe



Fri, 27 May 2005 02:03:48 GMT  
 Creating User Forms - Novice question
I use a command button on the form that does the following (keep in mind
that you need to use the textbox field names of the formfields you create):

Private Sub CommandButton1_Click()
    ActiveDocument.FormFields("Text1").Result = TextBox1
    ActiveDocument.FormFields("Text2").Result = TextBox2
    ActiveDocument.FormFields("Text3").Result = TextBox3
    ActiveDocument.Fields.Update
    Unload UserForm1
    ActiveDocument.Fields.Unlink
End Sub

Basically this takes the data you enter in TextBox1, 2, and 3 on your
UserForm and puts them in fields with Text1, 2, and 3 bookmark names.  If
you double-click on your text form field in your table, you should see a
bookmark name.  You can change it to whatever you want, just change the
corresponding name in the code for the button.  It also updates the fields
with the info, closes out the UserForm, then unlinks the data (no longer
fields).  you don't have to use that last line, but I do because I have a
tendency to unprotect the document, then if it gets protected again all the
data is lost.

Hope this helps!

Bill Foley
www.pttinc.com


Quote:
> I have a word table that I want a user to fill in.  However, rather than
> type directly into the table, I want them to enter the data via a form
(that
> looks like one I would normally create in Access).
> I can create the form with textboxes and comboboxes but have no idea how
to
> link these controls on the form to the fields in the table in Word.  I'm
> used to creating forms in Access but just cannot get them to work in Word.

> Can anyone help please?

> Many thanks in advance

> Joe



Fri, 27 May 2005 02:45:10 GMT  
 Creating User Forms - Novice question
Joe

If you mean 'form' as in a dialog box then what I suggest is that you
nip over to my site and download some of the Word templates there and
have a look at the code.
(http://www.dragondrop.com/WordCoding/default.asp)

Have a look at the letter template in particular.

If you are wanting to put the data into a table rather than to a
bookmark, as I tend to do, then you may want something like this:

ActiveDocument.Tables(2).Cell(2, 1).Range.Text = objForm.txtName.Text

Which will place the text of the textbox called txtName and place it
into the Text range of the particular cell within the second table.

Have a dip into the code and if you have any questions then do get
back to me.

Regards
  Malc
  www.dragondrop.com



Fri, 27 May 2005 05:33:22 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Creating App for user to create Forms and Controls with VB

2. Novice user MSComm run time error

3. Novice VB User Needs Help With VBA in Excel

4. Novice user needs HELP

5. User Level security Novice

6. Problem to create an user form

7. User forms created in 97 lose data in 2000

8. Problem creating user form

9. Creating Customized User Forms (or Customized letter wizard)

10. User Form created in Word 2002 viewable in lower versions

11. Tutorial: Creating a User Form

12. Create line or circle on user Forms

 

 
Powered by phpBB® Forum Software