Creating New Toolbars

You can create and add a new Toolbar object to the Toolbars collection through the Add method, which returns a reference to the new Toolbar object.

Set ToolbarObject = ToolbarsCollection.Add(ToolbarName)

Table 16-12 shows the Add method's parameter.

Table 16-12. The Add Method's Parameter


Data Type




The identifying name of the newly created Toolbar object

The following example illustrates how to create a new toolbar in the AutoCAD collection. A check is in place to ensure that a toolbar of the same name doesn't already exist, as this would cause an error to be raised.

Public Sub AddNewToolbar() Dim strTBName As String Dim objToolbar As AcadToolbar strTBName = InputBox("Please enter name for new toolbar") If strTBName = "" Then Exit Sub

On Error Resume Next

Set objToolbar = ThisDrawing.Application.MenuGroups.Item("ACAD"). _

Toolbars.Item(strTBName) If Not objToolbar Is Nothing Then

MsgBox "This toolbar already exists"


ThisDrawing.Application.MenuGroups.Item("ACAD").Toolbars.Add strTBName End If

Table 16-13. The AddToolbarButton Method's Parameters

Was this article helpful?

0 0

Post a comment