Background: I have an extensive set of specialized VBA macros used in Word for document formatting purposes. In Word 2003, these macros were activated from a customized toolbar. I have recently transitioned to Word 2007 and would like to be able to run these existing VBA macros from a new Word Ribbon created with VS 2010. I have created a Ribbon; however, I cannot figure out how to call the existing macros from the new Ribbon buttons.
Question: How do I call the existing VBA macros, which are stored in a .dotm template, from the C# Word Add-in?
Any help would be greatly appreciated.
Best Answer
The technique described in MS KB article 306683 -- in particular, function
RunMacro
defined there -- should allow you to call a VBA macro from within C# code: You define a functionRunMacro
and then call your macro like this:
or
oApp
is theWord.Application
object, which I'm sure is available somewhere in a Word add-in.