Question

Is it possible to configure a Ribbon (e.g. adding a tab etc.) in Office 2010 programatically via VBA? I.e. by writing VBScript code in a macro.

Br. Morten

Was it helpful?

Solution

You can manipulate a Ribbon tab and its controls using VBA, but you cannot create one. Not with the Object Model anyway. The best you could do - somehow - is to get some kind of OPC dll (like an ActiveX component) that handles opening/relationships/closing of OPC documents (like .docx documents) and old school MSXML for creating a ribbon definition and adding it to the package.

OTHER TIPS

If your UI is static, i.e. you don't need to programatically change the behavior of, or add/remove UI elements on the fly, you can define a customUI within a macro-enabled template. You can use your VBA functions as call-backs for the UI elements defined in the XML.

Have a look at this guide. In a nutshell, you define a customUI\customUI14.xml file within the .dotm archive. This XML describes your custom ribbon elements using this schema.

This definitely works for Word templates (.dotm files). I think a similar approach works for any OOXML format.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top