Remove Menu Commands, Menus, and Toolbar Buttons Example (VBA)
This example shows how to:
'----------------------------------------------------------------
'
' Preconditions: Part document is open.
'
' Postconditions:
' (1)
The Filter Edges toolbar button on the Selection
' Filter
toolbar is removed.
' (2)
The Suppress command on the context-sensitive
' menus
is removed and also removed from the main frame menu.
'
'----------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim parentName As String
Dim name As String
Sub main()
Set swApp = Application.SldWorks
' Get the name of the parent menu for the first occurrence
' of the Suppress command in part documents
name = swApp.GetMenuStrings(swCommands_Suppress,
1, parentName)
' Remove the Filter Edges button from the Selection Filter
toolbar
' in part documents
swApp.RemoveFromMenu
swCommands_FilterEdges, 1, 3, True
' Remove the Suppress command from all main frame menus
in part documents; do
' not remove the parent menus
swApp.RemoveFromMenu
swCommands_Suppress, 1, 3, False
' Remove the Suppress command from all context-sensitive
menus; do not
' remove the parent menus
swApp.RemoveFromPopupMenu
swCommands_Suppress, 1, swSelEVERYTHING, False
End Sub