Tech Support Guy banner
Status
Not open for further replies.

Forms and Word

763 views 3 replies 2 participants last post by  XL Guru 
#1 ·
Hello...

I am trying to create a form that people fill in and then the data is transferred into a new document created from a template. The Form now opens when the template is open (thank you XL Guru) but I cannot seem to get the data to transfer...

I have created a 'textform field option' in a cell in word which I have called 'Price' in the 'Bookmark:' section.

I have then entered the following code into the userform module (my user form is called userform1):

Private Sub btnUserOK_Click()

End Sub

Private Sub TextBoxPrice_Change()
vprice = UserForm1.TextBoxPrice.Text
ActiveDocument.FormFields("bkprice").Result = vprice
End Sub

I am quite new to all this so you will have to excuse my ignorance if this is complete garbage...

Do I have to enter the code into the 'Userform1 module' or the 'thisdocument' module.

I then have an OK button which I want to click and the data then be entered into the appropriate 'textform field option'

Any help will be greatly appreciated..

Thank you
 
See less See more
#2 ·
Word VBA is NOT my thing (dunno where Annie is lately).

Whatever button (AKA control) on the form you want to "do stuff", rightclick it & "View Code" and shove it in there.

eg:

Private Sub CommandButton1_Click()
vprice = UserForm1.TextBoxPrice.Text
ActiveDocument.FormFields("bkprice").Result = vprice
UserForm1.Hide
End Sub

HTH,
Andy
 
#4 ·
I'm probably not following you.

"vprice = UserForm1.TextBoxPrice.Text" assigns the textbox content to a variable named "vprice" ; for no apparent reason in this case.

To "get the form to enter it by clicking the OK button", you just need the code for that button to include a line such as:

ActiveDocument.FormFields("bkprice").Result = UserForm1.TextBoxPrice

Rgds,
Andy
 
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top