I have a VB.NET program that adds code to the ThisDocument module in MS Word in the following way:
wrdDoc.VBProject.VBComponents("ThisDocument").CodeModule.AddFromString(sCode)
Which creates the following sub:
Public Sub Example_Click()
Msgbox "Working"
End Sub
I used to call this via the click event of a command button however it would be desirable call it from a ribbon button created as part of a COM Add-In.
I have been able to call global macros successfully in the Add-In by adding the following code to the button's click sub,.
Globals.TestWordApp.Application.Run("Macro1")
All attempts to run code contained within ThisDocument have failed however.
Any help would be greatly appreciated.