Results 1 to 11 of 11
  1. #1
    New Lounger
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Displaying optional data when using Word 2003 userform

    I've created a template with userform in Word 2003. I know need to include a couple extra sentences (canned ones, always the same) based on either

    a check box that I can check in the userform
    or ideally,
    based on one of the selections in a resident combo box

    any help would be appreciated

    thanks
    Rhonda

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Rhonda,

    Welcome to the lounge.

    Would it be possible for you to post a picture of the userform along with the sentences you want displayed, the conditions that trigger their display, and where on the userform you want them displayed.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    New Lounger
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    posting the userform?

    I can't see how to attach the template/form, unfortunately.

    I have a combo box that lists several choices, and based on ONE of those choices would like an additional 2 sentences put in the .doc file.

    Alternatively, if I could use a checkbox to tell it to include the 2 sentences, that would also be fine.

    Rhonda

  4. #4
    Plutonium Lounger Medico's Avatar
    Join Date
    Dec 2009
    Location
    USA
    Posts
    12,631
    Thanks
    161
    Thanked 936 Times in 856 Posts
    Rhonda, I would also like to welcome you to the Lounge.

    Open the form, then use Prt Sc to take a snapshot, paste into paint, crop as needed and save to desktop. Go Advanced (in the reply area of the Lounge), Manage Attachments or use paperclip to upload the snapshot you took.
    BACKUP...BACKUP...BACKUP
    Have a Great Day! Ted


    Sony Vaio Laptop, 2.53 GHz Duo Core Intel CPU, 8 GB RAM, 320 GB HD
    Win 8 Pro (64 Bit), IE 10 (64 Bit)


    Complete PC Specs: By Speccy

  5. #5
    New Lounger
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    added form pic

    OK..I've added a snap of the form. thanks!
    Rhonda
    Attached Images Attached Images

  6. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Rhonda,

    I assume that you are talking about the "Type of Test" or "Respond to" combo boxes. If so here is what I'd do.
    1. Insert a bookmark in the Document/template where you want to insert the text if the desired option is selected.
    2. In the AfterUpdate event of the appropriate combobox test the current value and if it is the one that gets the extra sentences navigate to the bookmark.
    3. Insert the sentences.

    I know these instructions are general, that's because I don't write much VBA in Word I mostly use Access & Excel. If you need further help post back and I'll try to code it out and/or one of the Word experts will jump in I'm sure.

    P.S. If you post back include the name of the ComboBox and the Name of the Bookmark you insert. That will allow whoever does the code to use the proper names to give you copy & paste code.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. #7
    New Lounger
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes, that's exactly what I want to do....

    it's the test type combo box, the new bookmark will be called Area_requirements and the pick from the dropdown is "Area Type 1". I don't see an AfterUpdate event on the userform. I had to add this:

    Private Sub UserForm_Initialize()
    testtype.List = Array("Area Type 1", "Area Type 2", "Area Type 3", "Avalanche Type 1", "Cadaver Type 1", "Cadaver Type 2", "Cadaver Type 3", "Disaster Type 4", "Trailing Type 1", "Trailing Type 2", "Trailing Type 4")
    respond_to.List = Array("Area Type 1/2/3", "Area Type 2/3", "Avalanche Type 1", "Cadaver Type 1", "Cadaver Type 2", "Cadaver Type 3", "Disaster Type 4", "Trailing Type 1/2/4", "Trailing Type 2", "Trailing Type 4")
    End Sub

    to get the combo boxs populated.

    thanks!
    Rhonda

  8. #8
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Rhonda,

    The AfterUpdate method is on the ComboBox. So when the selection is made the event is triggered and the code executed.

    If you click on your ComboBox control {graphic 1} you'll get the VBA code screen {graphic 2} which has the Change event. Drop down the box on the right and scroll to the top and Click on AfterUpdate to add a stub for that event then fill in your code.
    Attached Images Attached Images
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  9. #9
    New Lounger
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    whew!!! got that far...thanks...now I just need to get the code right.

    thanks so much!!
    Rhonda

  10. #10
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Rhonda,

    This should get you started:
    Code:
    Private Sub UserForm_Initialize()
    
       TestType.List = Array("Area Type 1", "Area Type 2", "Area Type 3", _
                             "Avalanche Type 1", "Cadaver Type 1", _
                             "Cadaver Type 2", "Cadaver Type 3", _
                             "Disaster Type 4", "Trailing Type 1", _
                             "Trailing Type 2", "Trailing Type 4")
    respond_to.List = Array("Area Type 1/2/3", "Area Type 2/3", "Avalanche Type 1", _
                            "Cadaver Type 1", "Cadaver Type 2", "Cadaver Type 3", _
                            "Disaster Type 4", "Trailing Type 1/2/4", _
                            "Trailing Type 2", "Trailing Type 4")
    End Sub
    
    Private Sub TestType_AfterUpdate()
    
        Dim zMyValue As String  '*** Use variable so you don't repeatedly fetch value.
        
        zMyValue = TestType.Value
        
        MsgBox "The selection in TestType is: " & zMyValue
        
        If zMyValue = "Area Type 1" Then
        
          '*** Put code here to locate bookmark & insert sentences
          
        End If
     
    End Sub
    P.S. The AfterUpdate event does not fire until you leave the TestType dropdown!
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  11. #11
    New Lounger
    Join Date
    Jul 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks...let me bang on this a bit...

    thanks again!
    Rhonda

Tags for this Thread

Posting Permissions

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