如下面的程序,设置有两个按钮的工具条,第一个按钮是打开文件,第二个是删除物体, 在两个按钮中间放一个分隔符。 设置好后,关闭AutoCAD。当再次打开AutoCAD时,工具条中就只剩下 打开文件的按钮和分隔符了,删除物体的按钮消失了。 但如果不设置分隔符,就不会产生这个问题。 不知道为什么? Sub ToolbarButton() Dim currMenuGroup As AcadMenuGroup Dim newToolBar As AcadToolbar Dim newButton As AcadToolbarItem Dim openMacro As String Dim newToolBarSeparator As AcadToolbarItem Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item("ACAD") On Error Resume Next Set newToolBar = currMenuGroup.Toolbars.Add("Test") Set newToolBar = currMenuGroup.Toolbars.Item("Test") On Error GoTo 0 newToolBar.Visible = True For Each newButton In newToolBar If newButton.Type = acToolbarSeparator Then newButton.Delete End If Next For Each newButton In newToolBar newButton.Delete Next openMacro = Chr(3) & Chr(3) & Chr(95) & "open" & Chr(32) Set newButton = newToolBar.AddToolbarButton("", "Open", "Open a file.", openMacro) openMacro = Chr(3) & Chr(3) & Chr(95) & "erase" & Chr(32) Set newButton = newToolBar.AddToolbarButton("", "Erase", "erase object", openMacro) ''' Set newToolBarSeparator = newToolBar.AddSeparator(1) ''' currMenuGroup.Save acMenuFileCompiled End Sub |