Determinare quale pulsante CommandBar che ha iniziato una macro VBA utilizzando in Microsoft Excel
Consentire alle macro stesse di determinare il pulsante CommandBar che le ha avviate.
Se alleghi la macro di seguito a più pulsanti CommandBar, la finestra di messaggio visualizzerà contenuti diversi:
Sub DummyMacro() If Application.CommandBars.ActionControl Is Nothing Then ' the macro was not started from a commandbar button MsgBox "This could be your macro running!", vbInformation, _ "This macro was not started from a CommandBar button" Else ' the macro was started from a commandbar button MsgBox "This could be your macro running!", vbInformation, _ "This macro was started from this CommandBar button: " & _ Application.CommandBars.ActionControl.Caption End If End Sub