1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Forms and Word

Discussion in 'Business Applications' started by Fiddlercrab1, Nov 26, 2004.

Thread Status:
Not open for further replies.
Advertisement
  1. Fiddlercrab1

    Fiddlercrab1 Thread Starter

    Joined:
    Nov 11, 2004
    Messages:
    61
    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
     
  2. XL Guru

    XL Guru

    Joined:
    Aug 30, 2003
    Messages:
    2,702
    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
     
  3. Fiddlercrab1

    Fiddlercrab1 Thread Starter

    Joined:
    Nov 11, 2004
    Messages:
    61
    And to get the form to enter it by clicking the OK button?
     
  4. XL Guru

    XL Guru

    Joined:
    Aug 30, 2003
    Messages:
    2,702
    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
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/300986

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice