سؤال

Use case:

  1. user changes the value of a legacy Drop-Down Form Field from one thing to another. (In reality, he's assigning a Priority to something, and we have Low, Medium, High, or Emergency... each with a very specific and distinct definition.)
  2. priorityDefinitionLabel (a label just to the right of the drop-down box) is updated to show the definition of the selection made, to let the user make sure he's making the right choice by reading the definition and seeing if it applies to his problem.

My problem is that I can't seem to do something as basic as this:

Private Sub priorityDropDownBox_Changed()
    updatePriorityLabel()
End Sub

It seems that I cannot access any form field if it's a "Legacy Form Field" in the VBA code... however, if I throw an ActiveX Content Control on the page, I can access that in the code.

Is there any way to access/address that drop-down box? My entire Word form uses legacy form fields and dropdowns, so I'm hoping the answer is yes, otherwise I probably need to switch all the fields and dropdowns to ActiveX content controls.

Thanks!

هل كانت مفيدة؟

المحلول

The legacy controls are members of the Selection.FormFields collection. The do not have events, the nearest equivalents are the EntryMacro and ExitMacro properties.

Sub Macro2()
    Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown
    Selection.PreviousField.Select
    With Selection.FormFields(1)
        .Name = "Dropdown1"
        .EntryMacro = "Macro1"
        .ExitMacro = "Macro2"
        .Enabled = True
        .OwnHelp = False
        .HelpText = ""
        .OwnStatus = False
        .StatusText = ""
    End With
    Selection.FormFields("Dropdown1").DropDown.ListEntries.Clear
End Sub

The ExitMacro doesn't run on selecting, or changing, a drop-down item, but when tabbing away from the control.

There is some MS information here about these legacy controls.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top