AndrewMc
10-29-2013, 02:17 AM
Hi All
I am trying to modify an Excel add-in to work for Word 2007. While I am comfortable working with Excel VBA, I am new to using VBA with Word.
The Excel add-in is known as SourceTools.xla (hosted at CodeProject, sorry I can't yet post a link) and provides a toolbar in the VB Editor to enable working with a Subversion source repository.
While I am able to modify the code and change things like use of "ThisWorkbook" to "ThisDocument", and can run the code from within the VBE, I cannot seem to get the toolbar to appear. In Excel, simply opening the .xla file or loading the add-in causes Auto_Open() to run and make the new toolbar appear in the VBE. Similarly Auto_Close() is run to remove the toolbar when the .xla file is closed or the add-in unloaded.
Sub Auto_Open()
''' Create the VBE menu.
On Error Resume Next
Set gclsMenuHandler = New CMenuHandler
On Error GoTo 0
End Sub
Sub Auto_Close()
Set gclsMenuHandler = Nothing
End Sub
I have created a SourceTools.dot template file and have tried both opening the file in Word and loading the file as an add-in (via Word Options). In both cases, the Auto_Open code does not appear to run. I thought that perhaps Auto_Exec() is needed (see the code below) but that doesn't seem to work either.
Sub Auto_Exec()
''' Create the VBE menu.
MsgBox "Starting SourceTools Auto_Exec()..."
On Error Resume Next
Set gclsMenuHandler = New CMenuHandler
On Error GoTo 0
End Sub
Sub Auto_Exit()
Set gclsMenuHandler = Nothing
MsgBox "Exiting SourceTools, Auto_Exit()..."
End Sub
Does anyone have any suggestions for things I can try to get the toolbar generating code (or any code for that matter) to run when the template file is loaded?
Cheers
Andrew Mc
I am trying to modify an Excel add-in to work for Word 2007. While I am comfortable working with Excel VBA, I am new to using VBA with Word.
The Excel add-in is known as SourceTools.xla (hosted at CodeProject, sorry I can't yet post a link) and provides a toolbar in the VB Editor to enable working with a Subversion source repository.
While I am able to modify the code and change things like use of "ThisWorkbook" to "ThisDocument", and can run the code from within the VBE, I cannot seem to get the toolbar to appear. In Excel, simply opening the .xla file or loading the add-in causes Auto_Open() to run and make the new toolbar appear in the VBE. Similarly Auto_Close() is run to remove the toolbar when the .xla file is closed or the add-in unloaded.
Sub Auto_Open()
''' Create the VBE menu.
On Error Resume Next
Set gclsMenuHandler = New CMenuHandler
On Error GoTo 0
End Sub
Sub Auto_Close()
Set gclsMenuHandler = Nothing
End Sub
I have created a SourceTools.dot template file and have tried both opening the file in Word and loading the file as an add-in (via Word Options). In both cases, the Auto_Open code does not appear to run. I thought that perhaps Auto_Exec() is needed (see the code below) but that doesn't seem to work either.
Sub Auto_Exec()
''' Create the VBE menu.
MsgBox "Starting SourceTools Auto_Exec()..."
On Error Resume Next
Set gclsMenuHandler = New CMenuHandler
On Error GoTo 0
End Sub
Sub Auto_Exit()
Set gclsMenuHandler = Nothing
MsgBox "Exiting SourceTools, Auto_Exit()..."
End Sub
Does anyone have any suggestions for things I can try to get the toolbar generating code (or any code for that matter) to run when the template file is loaded?
Cheers
Andrew Mc