Button class
An addin-created toolbar button. Returned by Toolbar.AddButton; hold it via WithEvents to receive OnClick notifications. The button’s Caption and IconData are mutable at run time — change the caption to reflect a state, or swap the icon to reflect a toggle.
Private WithEvents RefreshButton As Button
Private Sub Host_OnProjectLoaded()
Set RefreshButton = Host.Toolbars(0).AddButton("MyAddIn.Refresh", "Refresh project", _
LoadResData("refresh.png", "ICONS"))
End Sub
Private Sub RefreshButton_OnClick()
Host.CurrentProject.Save
End Sub
Properties
Caption
The button’s caption. String. When IconData is set, the caption is shown as a tooltip on hover. When IconData is empty, the caption is shown inline as the button’s text. Read / write.
Syntax: button.Caption [ = value ]
IconData
The icon graphic as a Byte() array — typically the bytes of an embedded PNG / ICO resource. Pass Empty to remove the icon and fall back to showing the Caption inline. Read / write.
Syntax: button.IconData [ = bytes ]
- bytes
- A Byte() array (or Empty). Variant.
ID
The unique ID assigned to the button when it was created via Toolbar.AddButton. String, read-only.
Events
OnClick
Fires when the user clicks the button.
Syntax: button_OnClick()