Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Sep 2003
    Location
    Bad Voeslau, Austria
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word Forms with macro (Word 2000 SR3)

    This Problem may be more of a VBA problem, than a Word one ... ?
    I want to create a Word form (sample file FormTest.doc) using - among others - two check boxes for "Yes" and "No" and a dropdown field containing various entries for selection in the case of "Yes". To prevent users selecting (or unselecting) both boxes I created macros (JaFlipflop and NeinFlipflop, FormMacros section in the .doc) so that selecting one box will unselect the other and vice versa. Worked so far.
    Then I wanted to improve: if "No" is selected it makes no sense to select anything from the dropdown. So - in the of "No" - I want the first List item to show ("leer" meaning empty). Got that one easily. Then I wanted to disable the dropdown, so nothing else could be selected. The only way found is in FormMacros1, I tried all sorts of code, finally got there by recording a "GoTo". Works - mostly.
    Trying to get fancy has me stumped: Should the user return to the "Yes" field, the dropdown should be enabled again. Doing the "Else" branch with ...enabled=True does not work, but gives an error. It looks like Word cannot find the disabled field!
    What did I do wrong?
    Attached Files Attached Files

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

    Re: Word Forms with macro (Word 2000 SR3)

    Do these macros do what you want?

    Sub JaFlipFlop()
    If ActiveDocument.FormFields("check1").CheckBox.Value = True Then
    ActiveDocument.FormFields("check2").CheckBox.Value = False
    ActiveDocument.FormFields("dropdown1").Enabled = True
    Else
    ActiveDocument.FormFields("check2").CheckBox.Value = True
    ActiveDocument.FormFields("dropdown1").DropDown.Va lue = 1
    ActiveDocument.FormFields("dropdown1").Enabled = False
    End If
    End Sub

    Sub NeinFlipFlop()
    If ActiveDocument.FormFields("check2").CheckBox.Value = True Then
    ActiveDocument.FormFields("check1").CheckBox.Value = False
    ActiveDocument.FormFields("dropdown1").DropDown.Va lue = 1
    ActiveDocument.FormFields("dropdown1").Enabled = False
    Else
    ActiveDocument.FormFields("check1").CheckBox.Value = True
    ActiveDocument.FormFields("dropdown1").Enabled = True
    End If
    End Sub

    See attached version.
    Attached Files Attached Files

  3. #3
    New Lounger
    Join Date
    Sep 2003
    Location
    Bad Voeslau, Austria
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Forms with macro (Word 2000 SR3)

    Works fine, thanks! I knew there must be a simple way to do it. actually I tried something very similar, but in the line containing the "enabled" I added the field type "DropDown" as in the line setting the "Value". This did work for disabling, but not for enabling ... so it got me on an obviously completely wrong track!
    My trust in the lounge and its members once more justified!

Posting Permissions

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