Menubutton als Schalter
21.09.2003 09:28:22
Wolfgang
Beim Pressen des Buttons wird auch das Makro Overdues_lineup ausgelöst, jedoch beim zweiten klick leider nicht das Makro Standardview. Es kommt auch keine Fehlermeldung. Habe ich die Makroaufrufe falsch eingebaut?
Sub Makroschalter()
Call CBCtlToggleState("Test")
End Sub
Function CBCtlToggleState(strCBarName As String, _
Optional strCtlCaption As String) As Boolean
' Toggle the State property of the strCtlCaption control
' on the strCBarName command bar. The State property is
' read-only for built-in controls, so if strCtlCaption
' is a built-in control, return False and exit the procedure.
Dim ctlCBarControl As CommandBarControl
On Error Resume Next
Set ctlCBarControl = Application.CommandBars("Formatting").Controls("Test")
If ctlCBarControl.BuiltIn = True Then
CBCtlToggleState = False
Exit Function
End If
If ctlCBarControl.Type <> msoControlButton Then
CBCtlToggleState = False
Exit Function
End If
ctlCBarControl.State = Not ctlCBarControl.State
If Err = 0 Then
Call Overdues_lineup
CBCtlToggleState = True
Else
Call Standardview
CBCtlToggleState = False
End If
End Function