Run Macro from Content Control Drop Down List in Microsoft Word

Mattie Owens
Mattie Owens used Ask the Experts™
on
Microsoft Word VBA

I'd like to run a macro based on the selection from a control content drop down list. Is this possible.

If not, how do I copy the content to another cell, and maybe run the macro based on the new cell value.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
NorieAnalyst Assistant

Commented:
Mattie

Is it one macro that is executed when the selection changes or are there multiple macros and you want to determine which to call/run based on what's been selected?

Author

Commented:
Its a couple

If its orange run macro 1
if its blue run macro 2
if its green run macro 3
else do nothing

Author

Commented:
is it possible
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Retired
Top Expert 2012
Commented:
Yes, You would need a macro to launch one of a number of macros, depending on the selected item in the Content Control.

Sub MainMacro()
    Dim cc As ContentControl
    Set cc = ActiveDocument.ContentControls(1)
    Select Case cc.Range.Text
        Case "Item 1"
            Call Macro1
        Case "Item 2"
            Call Macro2
    End Select
End Sub

Sub Macro1()
    MsgBox "One"
End Sub

Sub Macro2()
    MsgBox "Two"
End Sub

Open in new window

Author

Commented:
How do I determine what the control number is? Do I place the code in a regular module

Author

Commented:
Okay it works except that it runs before I even make a selection
GrahamSkanRetired
Top Expert 2012

Commented:
Are you saying that you want the macro to start when you have changed the selection?

Author

Commented:
Once I understood it. It worked perfectly.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial