这里有一个又快又脏的,其中一半是从帮助文件中偷来的。 
它动态创建工具栏,并将VBA子例程附加到它添加的每个按钮。希望它能让你开始。 
  
  
- Sub ToolbarButton()
-    
-    Dim currMenuGroup As AcadMenuGroup
-    Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
-    
-    ' Create the new toolbar
-    Dim newToolBar As AcadToolbar
-    Set newToolBar = currMenuGroup.Toolbars.Add("TestToolbar5")
-    
-    ' Add a button to the new toolbar
-    Dim newButton1 As AcadToolbarItem, newButton2 As AcadToolbarItem
-    Dim openMacro1 As String, openMacro2 As String
-    
-    ' Assign the macro string the VB equivalent of "ESC ESC _open "
-     openMacro1 = "-VBARUN " & "SampleSub1" & " " ' add a space to enmnu item to emulate the ENTER key]'
-     Set newButton1 = newToolBar.AddToolbarButton("", "NewButton1", "Sample Macro 1", openMacro1)
-     
-     ' Assign the macro string the VB equivalent of "ESC ESC _open "
-     openMacro2 = "-VBARUN " & "SampleSub2" & " " ' add a space to enmnu item to emulate the ENTER key]'
-     Set newButton2 = newToolBar.AddToolbarButton("", "NewButton2", "Sample Macro 2", openMacro2)
-    
-    ' Display the toolbar
-    newToolBar.Visible = True
-    
- End Sub
- Sub SampleSub1()
-    Dim tmpLayer As AcadLayer
-    Set tmpLayer = ThisDrawing.Layers.Item("0")
-    ThisDrawing.ActiveLayer = tmpLayer
-    ThisDrawing.SendCommand "Line "
- End Sub
- Sub SampleSub2()
-    Dim tmpLayer As AcadLayer
-    Set tmpLayer = ThisDrawing.Layers.Item("0")
-    ThisDrawing.ActiveLayer = tmpLayer
-    ThisDrawing.SendCommand "Circle "
- End Sub
                                     
 
  |