C
Col
Hi all,
I added two buttons to the QAT to run specific macros.
I need to be able to disable one or both of them depending on the loaded
document.
I could do it with Office 2K3 and command bars but the QAT is a different
animal.
'****************2K3 code to set the enabled property of a button
Function CommandBarEnable(boolIN As Boolean, strBUTNLBL As String) As
Boolean
On Error GoTo Err_CommandBarEnable
Dim fFound As Boolean
Dim mCommandBar As CommandBar
Dim intI As Integer
fFound = False
For Each mCommandBar In CommandBars
For intI = 1 To mCommandBar.Controls.Count
If mCommandBar.Controls(intI).Caption = strBUTNLBL Then
fFound = True
mCommandBar.Controls(intI).Enabled = boolIN
Exit For
End If
Next
If fFound Then
Exit For
End If
Next
CommandBarEnable = fFound
Exit_CommandBarEnable:
Exit Function
Err_CommandBarEnable:
If Err.Number = 13 Then
Resume Next
Else
MsgBox Err.Number & " " & Err.Description, vbOKOnly + vbExclamation,
"ERROR DETECTED"
Resume Exit_CommandBarEnable
End If
End Function
'************************************************
How is this done for the buttons on the Quick Access Toolbar?
Regards
Col
I added two buttons to the QAT to run specific macros.
I need to be able to disable one or both of them depending on the loaded
document.
I could do it with Office 2K3 and command bars but the QAT is a different
animal.
'****************2K3 code to set the enabled property of a button
Function CommandBarEnable(boolIN As Boolean, strBUTNLBL As String) As
Boolean
On Error GoTo Err_CommandBarEnable
Dim fFound As Boolean
Dim mCommandBar As CommandBar
Dim intI As Integer
fFound = False
For Each mCommandBar In CommandBars
For intI = 1 To mCommandBar.Controls.Count
If mCommandBar.Controls(intI).Caption = strBUTNLBL Then
fFound = True
mCommandBar.Controls(intI).Enabled = boolIN
Exit For
End If
Next
If fFound Then
Exit For
End If
Next
CommandBarEnable = fFound
Exit_CommandBarEnable:
Exit Function
Err_CommandBarEnable:
If Err.Number = 13 Then
Resume Next
Else
MsgBox Err.Number & " " & Err.Description, vbOKOnly + vbExclamation,
"ERROR DETECTED"
Resume Exit_CommandBarEnable
End If
End Function
'************************************************
How is this done for the buttons on the Quick Access Toolbar?
Regards
Col