Using Word 2000 on Windows 2000. I’ve created a toolbar button which calls a macro that loads a template so that it will show the template’s toolbar. The button works like a toggle to close the toolbar as well, but I can’t find a way to actually UNload the template (i.e., so that it’s not checked in the templates and addins dialog). This is desirable since this particular template is in conflict with one of our global templates (overriding some of its menu items). Below is my code. I hope one of you gurus out there can help me figure this one out. Thanks very much.
Public Sub ShowWestCheckButton()
Dim iAddInCnt As Integer, sAddInName As String
Dim iCnt As Integer, bToolBarFound As Boolean
Dim bShowToolBar As Boolean, bcShowToolBar As Boolean
Dim sSecondaryTemplates$
On Error GoTo ErrorRoutine
sSecondaryTemplates$ = Environ(“userprofile”)
sSecondaryTemplates$ = sSecondaryTemplates$ & “Application DataMicrosoftAddins”
iCnt = 1
iAddInCnt = AddIns.Count
Do While iCnt <= iAddInCnt
sAddInName = AddIns.Item(iCnt).Name
If sAddInName = "West Group Westcheck.dot" Then
bToolBarFound = True
Exit Do
Else
iCnt = iCnt + 1
End If
Loop
If bToolBarFound = True Then
bShowToolBar = CommandBars("Westcheck").Visible
AddIns(sSecondaryTemplates$ & "West Group Westcheck.dot").Installed = True
bcShowToolBar = CommandBars("Westcheck").Visible
ActiveDocument.UpdateStylesOnOpen = False
If bShowToolBar = False And bcShowToolBar = True Then
'Just Position, it's already visible
CommandBars("Westcheck").Position = msoBarTop
CommandBars("Westcheck").Left = 100
CommandBars("Westcheck").Top = 104
ElseIf bShowToolBar = True And bcShowToolBar = True Then
CommandBars("Westcheck").Visible = False
ElseIf bShowToolBar = False And bcShowToolBar = False Then
CommandBars("Westcheck").Visible = True
CommandBars("Westcheck").Position = msoBarTop
CommandBars("Westcheck").Left = 100
CommandBars("Westcheck").Top = 104
End If
Else
AddIns.Add FileName:=sSecondaryTemplates$ & "West Group Westcheck.dot", Install:=True
ActiveDocument.UpdateStylesOnOpen = False
CommandBars("Westcheck").Visible = True
End If
Exit Sub
ErrorRoutine:
If Err.Number = 5180 Then
MsgBox "Word cannot open this document template." + Chr(13) + Chr(13) + "The Template being sought may not be" + Chr(13) + "resident in the Word template Directory.", 48, "Word cannot open . . ."
ElseIf Err.Number = 5 Then
Err.Clear
Resume Next
Else
MsgBox "Error Number " & Err.Number & " Has Occurred " + Chr(13) + Error
End If
End Sub