Consulting

Results 1 to 8 of 8

Thread: Command Button to extract data from UserForm

  1. #1
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location

    Command Button to extract data from UserForm

    I have a WorkBook in which I have created several userforms, which
    thankfully are working well. The userforms contain checkboxes. What I would like to do is create a command button on those forms.

    When clicking this button, I would like for the unchecked boxes to be populated onto a word document. Is this
    possible to do? Can anyone direct me on getting started?

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    What is it you want to put on a word document? The label values of the checkboxes, whether they are checked or not or what exactly?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    I would like the label values and whether they are checked or not. Would it help to see the sheet? I will attach. The forms are in L, N, O, P, and Q

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I couldn't get your file to run. You really need to put option explicit at the top of each module.....see attachment, and declare your variable, etc.


    See if this gives you an idea of how you might go about it.....see attached.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    Thank you Lucas for your help. I am working with the example you provided now. Very Helpful!!!

  6. #6
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    [VBA]Private Sub CommandButton1_Click()
    Dim Appword As New Word.Application[/VBA]

    There is an error saying "user-defined typed not defined" when I utilize this code in my sheet...Where do I define the object and how? Thanks

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    If you had read the comments in the code you would have noticed this line:

    'This code requires a referece to the Word object model

    Which means that in the vbe you need to go to tools-referenced and put a check next to the

    microsoft word 11.0 object library

    11.0 may vary depending on which version of Excel you are using. 11.0 is what you would see if you are using Excel 2003. If it is an earlier version it might be 10.0, etc.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    VBAX Regular
    Joined
    Feb 2009
    Posts
    31
    Location
    I got it!! YEAAA...THANK you THANK YOU

Posting Permissions

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