Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Nov 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    User Form in Word (VBA6)

    I think this is a very basic question, but I am just starting off with user forms.
    Once a variable has been assigned from a text box within a user form, how can I pass this vairable into my Word Template?
    Many Thanks
    Junglefever

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: User Form in Word (VBA6)

    > how can I pass this vairable into my Word Template?

    There are several options:
    <UL><LI>You can create a global variable; such a variable will be available to all code within a template (and the documents attached to it). You *must* declare a global variable in a standard module (the one you create with Insert/Module). Variables in the module attached to a user form are not global.
    <LI>You can assign the value to a document variable; document variables are stored in the document. Look up the Variables collection in Word VBA help.
    <LI>You can assign the value to a custom document property; these are also stored in the document. Look up the DocumentProperties collection in Word VBA help.[/list]Global variables only "live" while the template is open. Document variables and document properties are stored in the document, so can be used to store "permanent" info.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: User Form in Word (VBA6)

    In addition to the methods of storage Hans has listed, you can go ahead and type/paste it into your template when the user clicks the OK button by adding the code into the form module. For example:

    Selection.TypeText Me.TextBox1.Value

    If you need more help with that part, post again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •