Option Explicit Sub CommonToolsToolbar_Create() Dim iCount1 As Integer Dim oCommandMgr As CommandManager Set oCommandMgr = ThisApplication.CommandManager Dim oControlDefinitions As ControlDefinitions Set oControlDefinitions = ThisApplication.CommandManager.ControlDefinitions ' Set a reference to the collection of ControlDefinitions Dim oControlDefs As ControlDefinitions Set oControlDefs = oCommandMgr.ControlDefinitions On Error Resume Next ' Create a macro definition Dim oMacroDef As MacroControlDefinition Set oMacroDef = oControlDefs.Item("macro:Toolbars.DisplayMessage") If oMacroDef Is Nothing Then Set oMacroDef = oControlDefs.AddMacroControlDefinition("Toolbars.DisplayMessage") End If ' Set a reference to the Part Standard toolbar Dim oCommonToolsBar As CommandBar Dim oCommandBar As CommandBar Dim bFound As Boolean bFound = False For Each oCommandBar In ThisApplication.UserInterfaceManager.CommandBars If oCommandBar.DisplayName = "Common Tools" Then oCommandBar.Visible = True bFound = True Set oCommonToolsBar = oCommandBar Exit For End If Next Set oCommandBar = Nothing If oCommonToolsBar Is Nothing Then Set oCommonToolsBar = ThisApplication.UserInterfaceManager.CommandBars.Add("Common Tools", "intTestBar", kRegularCommandBar, "CLSID of the Common Tools AddIn") End If ' Add a macro control to the toolbar Dim oButtonDefinition() As ButtonDefinition ReDim oButtonDefinition(11) Dim sDisplayName() As String ReDim sDisplayName(11) sDisplayName(0) = "Save As...": sDisplayName(1) = "Edit": sDisplayName(2) = "LogOut": sDisplayName(3) = "Log In" sDisplayName(4) = "SAP View": sDisplayName(5) = "CAD View": sDisplayName(6) = "Check out": sDisplayName(7) = "Save Interm." sDisplayName(8) = "Assign Matl": sDisplayName(9) = "Edit Matl": sDisplayName(10) = "LogOut": sDisplayName(11) = "New Matl" Dim oLargeIcon() As IPictureDisp Dim oSmallIcon() As IPictureDisp ReDim oLargeIcon(11) As IPictureDisp ReDim oSmallIcon(11) As IPictureDisp 'Set oLargeIcon(0) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\SaveAs_24x24.bmp") 'Set oSmallIcon(0) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\SaveAs_16x16.bmp") 'Set oLargeIcon(1) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oSmallIcon(1) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oLargeIcon(2) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oSmallIcon(2) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oLargeIcon(3) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oSmallIcon(3) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oLargeIcon(4) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oSmallIcon(4) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oLargeIcon(5) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oSmallIcon(5) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oLargeIcon(6) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oSmallIcon(6) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oLargeIcon(7) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oSmallIcon(7) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oLargeIcon(8) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oSmallIcon(8) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oLargeIcon(9) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oSmallIcon(9) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons\") 'Set oLargeIcon(10) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons") 'Set oSmallIcon(10) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons") 'Set oLargeIcon(11) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons") 'Set oSmallIcon(11) = LoadPicture("P:\Inventor2012\Inventor\Macros\Icons") For iCount1 = 0 To 11 oCommonToolsBar.Visible = True Set oButtonDefinition(iCount1) = oControlDefinitions.AddButtonDefinition(sDisplayName(iCount1), "HCCustBtn_" & iCount1, _ kShapeEditCmdType, , "Description Text", "Tooltip", oSmallIcon(iCount1), oLargeIcon(iCount1), kDisplayTextInLearningMode) Next iCount1 For iCount1 = 0 To 11 Call oCommonToolsBar.Controls.AddButton(oButtonDefinition(iCount1)) Next iCount1 'Dim oMacroControl As CommandBarControl 'Set oMacroControl = oCommonToolsBar.Controls.AddMacro(oMacroDef) ' Enable the control 'oMacroDef.Enabled = True oCommonToolsBar.Visible = True End Sub Public Sub CommonToolsToolbar_Delete() ' Set a reference to the "Common Tools" Standard toolbar Dim oCommonToolsBar As CommandBar Dim oCommandBar As CommandBar Dim bFound As Boolean For Each oCommandBar In ThisApplication.UserInterfaceManager.CommandBars If oCommandBar.DisplayName = "Common Tools" Then oCommandBar.Visible = True bFound = True Set oCommonToolsBar = oCommandBar Exit For End If Next Set oCommandBar = Nothing Dim iCounter As Integer iCounter = 1 If bFound = True Then Dim oControl For Each oControl In oCommonToolsBar.Controls oControl.Delete Set oControl = Nothing Next oCommonToolsBar.Visible = True oCommonToolsBar.Delete End If End Sub