关于向工具栏添加新工具栏按钮 (VBA/ActiveX)
若要将新的工具栏按钮添加到工具栏,请使用该方法。此方法创建一个新对象并将其添加到指定的工具栏中。AddToolbarButtonToolbarItem 只有在工具栏可见时,才应向工具栏添加按钮。 该方法采用五个参数作为输入:Index、Name、HelpString、Macro 和 FlyoutButton。AddToolbarButton
将按钮添加到新工具栏本示例创建一个新工具栏,并向该工具栏添加一个按钮。为按钮分配一个宏,该宏将在选择按钮时执行 OPEN 命令。 Sub Ch6_AddButton()
Dim currMenuGroup As AcadMenuGroup
Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
' Create the new toolbar
Dim newToolbar As AcadToolbar
Set newToolbar = currMenuGroup.Toolbars.Add("TestToolbar")
' Add a button to the new toolbar
Dim newButton As AcadToolbarItem
Dim openMacro As String
' Assign the macro the VB equivalent of "ESC ESC _open "
openMacro = Chr(3) + Chr(3) + "_open "
Set newButton = newToolbar.AddToolbarButton _
("", "NewButton", "Open a file.", openMacro)
End Sub
相关概念 |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-27 23:22
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.