J
Jeffrey Grantz
I have added a commandbar button to my Word document and it works. However,
I want my button only visible in a subset of my open Word windows. How can
I turn the button visible for one group of Word windows and invisible for
others? I have tried using the WindowActivate and WindowDeactivate. The
deactivate does turn it off when I leave the window, but the Activate turns
it on whenever I go to a different Word window.
Thanks for any help.
Private Sub AppEventHandler_WindowActivate(ByVal Doc As Document, ByVal Wn
As Window)
Dim oMenuBar As CommandBar
Dim I As Integer
Set oMenuBar = CommandBars.Item("Standard")
For I = 1 To oMenuBar.Controls.Count
If I > 28 Then
I = I
End If
If oMenuBar.Controls(I).Caption = "&" + Hdr Then '"&MyGoTo" Then
'oMenuBar.Controls(I).Delete
oMenuBar.Controls(I).Visible = True
Exit For
End If
Next I
End Sub
Private Sub AppEventHandler_WindowDeactivate(ByVal Doc As Document, ByVal Wn
As Window)
Dim oMenuBar As CommandBar
Dim I As Integer
Set oMenuBar = CommandBars.Item("Standard")
For I = 1 To oMenuBar.Controls.Count
If I > 28 Then
I = I
End If
If oMenuBar.Controls(I).Caption = "&" + Hdr Then '"&MyGoTo" Then
'oMenuBar.Controls(I).Delete
oMenuBar.Controls(I).Visible = False
Exit For
End If
Next I
End Sub
I want my button only visible in a subset of my open Word windows. How can
I turn the button visible for one group of Word windows and invisible for
others? I have tried using the WindowActivate and WindowDeactivate. The
deactivate does turn it off when I leave the window, but the Activate turns
it on whenever I go to a different Word window.
Thanks for any help.
Private Sub AppEventHandler_WindowActivate(ByVal Doc As Document, ByVal Wn
As Window)
Dim oMenuBar As CommandBar
Dim I As Integer
Set oMenuBar = CommandBars.Item("Standard")
For I = 1 To oMenuBar.Controls.Count
If I > 28 Then
I = I
End If
If oMenuBar.Controls(I).Caption = "&" + Hdr Then '"&MyGoTo" Then
'oMenuBar.Controls(I).Delete
oMenuBar.Controls(I).Visible = True
Exit For
End If
Next I
End Sub
Private Sub AppEventHandler_WindowDeactivate(ByVal Doc As Document, ByVal Wn
As Window)
Dim oMenuBar As CommandBar
Dim I As Integer
Set oMenuBar = CommandBars.Item("Standard")
For I = 1 To oMenuBar.Controls.Count
If I > 28 Then
I = I
End If
If oMenuBar.Controls(I).Caption = "&" + Hdr Then '"&MyGoTo" Then
'oMenuBar.Controls(I).Delete
oMenuBar.Controls(I).Visible = False
Exit For
End If
Next I
End Sub