Home > Blockchain >  Call Word Menu-Button in VBA?
Call Word Menu-Button in VBA?

Time:06-16

everyone,

I am new to VBA and would like to know if it is possible to execute a menu button from a WordAddIn.

In the picture you can see which button I would like to execute using VBA.

Unfortunately, I can't record it via macro.

CodePudding user response:

The Word object model allows executing built-in ribbon controls using the CommandBars.ExecuteMso method which executes the control identified by the idMso parameter. This method is useful in cases where there is no object model for a particular command. Works on controls that are built-in buttons, toggleButtons, and splitButtons.

But in your case the control comes from a third-party add-in which doesn't expose IDs and the CommandBars.ExecuteMso method can't find it and invoke the command programmatically.

To get the job done you may consider using the Microsoft Active Accessibility which is a Component Object Model (COM)-based technology that improves the way accessibility aids work with applications running on Microsoft Windows. It provides dynamic-link libraries that are incorporated into the operating system as well as a COM interface and API elements that provide reliable methods for exposing information about UI elements.

Also you may contact the add-in vendor for providing public methods that can be called from your solution. That's also a possible workaround instead of calling UI elements on the ribbon.

  • Related