Share via

Show Text and Text Fields Based on Dropdown Selection in Word

Anonymous
2021-09-16T23:01:37+00:00

I have created a template with Legacy Forms controls and I have a dropdown named Status with two choices: Denied and Approved.

If Denied is chosen from the dropdown Status, I would like to have the following text appear with a text form field:

Reason for denial: [Text Form Field named Reason]

If Approved is chosen from the dropdown Status, I would like to have the following text appear with these text form fields:

Monthly allotment: [Text Form Field named Allotment (this is a number field with calculate on exit checked)] / days in month: [Text Form Field named Days (this is a number field with calculate on exit checked)] = daily issuance amount: [Text Form Field named Amount (this is a calculation field with the expression of = Allotment/Days (this is a number field with calculate on exit checked)].

Note: I used [ ] to indicate the text field.

I would need to have the form stay locked/protected so the user could tab into and enter information in the form fields that appear when Denied or Approved is chosen.

Is this possible? If so, the coding to make this happen would be appreciated.

Thank you, Jamie

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

5 answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2021-09-17T02:26:34+00:00

    I would insert both pieces of text into the document and have one inside a bookmark Denied and the other inside a bookmark Approved

    Then in a macro run on exit from the Status DropDown Formfield have the following code

    Sub StatusExit()

    With ActiveDocument

    If .FormFields("Status").DropDown.Value = "Approved" Then 
    
        .Unprotect 
    
        .Bookmarks("Approved").Range.Font.Hidden = False 
    
        .Bookmarks("Denied").Range.Font.Hidden = True 
    
        .Protect wdAllowOnlyFormFields, True 
    
    Else 
    
        .Unprotect 
    
        .Bookmarks("Approved").Range.Font.Hidden = True 
    
        .Bookmarks("Denied").Range.Font.Hidden = False 
    
        .Protect wdAllowOnlyFormFields, True 
    
    End If 
    

    End With

    End Sub

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  2. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2021-09-18T00:10:06+00:00

    If you send me a copy of the document, referencing this thread in the covering email message, I will investigate the issue.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Charles Kenyon 167.8K Reputation points Volunteer Moderator
    2021-09-17T02:30:03+00:00

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  4. Anonymous
    2021-09-20T16:40:30+00:00

    Hi Doug, I have sent you the document.

    Thanks, Jamie

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2021-09-17T18:01:21+00:00

    Hi Doug, thank you for your response. I read it a couple of times and I’m not sure I’m doing this right, so bear with me.

    You said insert both pieces of text into the document and have one inside a bookmark Denied and the other inside a bookmark Approved.

    So I highlighted the Denied text and formfield, clicked on Insert, Bookmark and named it Denied. I highlighted the Approved text and formfields and named that Bookmark Approved.

    Then I entered the coding you provided and made it an on exit macro on the Status dropdown formfield.

    I protected the document and tested this and when I tab out of the Status dropdown, regardless of whether I choose Denied or Approved, I receive the following error message – Type mismatch.

    I’m afraid I need further help with this as I don’t understand what that error message means.

    Was this answer helpful?

    0 comments No comments