A
Alan
I created a VBA macro and turned it into a Word (2007) Add-In saved
in a template. Every time I open the document, it adds another copy
of the same macro to the Add-In command menu. The code I am using to
automatically start and exit the add-in is shown below.
Should I be doing something differently to avoid this
problem?
Thanks, Alan
Public Sub AutoExec()
Dim objcommandbutton As CommandBarButton
Set objcommandbutton = Application.CommandBars
("Tools").Controls.Add _
(Type:=msoControlButton,
Before:=1)
objcommandbutton.Caption = "Get Selected Text"
objcommandbutton.OnAction = "GetSelectedText"
End Sub
Public Sub AutoExit()
Dim objcommandbutton As CommandBarControl
For Each objcommandbutton In Application.CommandBars
("Tools").Controls
If objcommandbutton.Caption = "Get Selected Text" Then
objcommandbutton.Delete
End If
Next objcommandbutton
End Sub
in a template. Every time I open the document, it adds another copy
of the same macro to the Add-In command menu. The code I am using to
automatically start and exit the add-in is shown below.
Should I be doing something differently to avoid this
problem?
Thanks, Alan
Public Sub AutoExec()
Dim objcommandbutton As CommandBarButton
Set objcommandbutton = Application.CommandBars
("Tools").Controls.Add _
(Type:=msoControlButton,
Before:=1)
objcommandbutton.Caption = "Get Selected Text"
objcommandbutton.OnAction = "GetSelectedText"
End Sub
Public Sub AutoExit()
Dim objcommandbutton As CommandBarControl
For Each objcommandbutton In Application.CommandBars
("Tools").Controls
If objcommandbutton.Caption = "Get Selected Text" Then
objcommandbutton.Delete
End If
Next objcommandbutton
End Sub