跳到主要内容

index

This VBA macro demonstrates how to flash standard toolbar buttons in SOLIDWORKS toolbar, similar to SOLIDWORKS tutorial files.

Flash Sketch Line Command

To flash a toolbar, you need to find its id. Please refer to the Calling Windows Command section in the blog post to learn how to obtain the id.

Note that the id of the command is persistent across SOLIDWORKS sessions and versions.

Unlike standard commands, custom commands added using SOLIDWORKS add-ins are not persistent across different installations. To dynamically obtain the id of a custom command, use the ISldWorks::GetCommandID API and pass the persistent command user id and the guid of the add-in.

Dim swApp As SldWorks.SldWorks

Sub main()

Set swApp = Application.SldWorks

'Flash the line button and show tooltip
FlashToolbarButton 32873

'Show tooltip for new file button only
FlashToolbarButton 57600, True

End Sub

Sub FlashToolbarButton(buttonId As Long, Optional tooltipOnly As Boolean = False)

swApp.ShowBubbleTooltip buttonId, IIf(tooltipOnly, "", CStr(buttonId)), 0, "", ""

End Sub