Home AutoCad VB Create AutoCad Toolbar
20 | 05 | 2012
This site has been updated and renewed. You have followed an old link.

Click here to go to the new site

http://www.visiblevisual.com/jupgrade

Create AutoCad Toolbar PDF Print E-mail
User Rating: / 1
PoorBest 
Tutorials

Use the code below to create a AutoCad Toolbar from VB or VBA

Show/Hidden vbnet code

View source
'--------------------------------------------------------------
 
	Sub CreateVBAToolBar()
 
	'--------------------------------------------------------------
 
 
 
	'****************************************
 
	'*** Code from VisibleVisual.com ********
 
	'****************************************
 
 
 
	Dim ObjToolbrs As AcadToolbars
 
	Dim ObjToolbr As AcadToolbar
 
	Dim ObjToolbrItem As AcadToolbarItem
 
	Dim ToolBarname As String
 
	Dim BMPlocation As String
 
 
 
	ToolBarname = "VisibleVisual" 'Set Toolbar Name
 
	BMPlocation = ".\" 'Set buttonimage location
 
 
 
 
 
	Set ObjToolbrs = ThisDrawing.Application.MenuGroups.Item(0).Toolbars
 
 
 
	'CREATE TOOLBAR
 
 
 
	On Error Resume Next
 
	'Check if the Toolbar exists if so then delete it first before creating it
 
	Set ObjToolbr = ObjToolbrs.Add(ToolBarname)
 
	If Err Then
 
	Set ObjToolbr = ObjToolbrs.Item(ToolBarname)
 
	ObjToolbr.Delete
 
	Set ObjToolbr = ObjToolbrs.Add(ToolBarname)
 
	End If
 
 
 
	'CREATE TOOLBAR BUTTON
 
 
 
	'Sample of Circle Button
 
	Set ObjToolbrItem = ObjToolbr.AddToolbarButton(0, "Circle", "Add Circle", "Circle ")
 
	Call ObjToolbrItem.SetBitmaps("Circle.BMP", BMPlocation & "Circle.BMP")
 
 
 
	'Sample of Line Button
 
	Set ObjToolbrItem = ObjToolbr.AddToolbarButton(0, "Line", "Add Line", "Line ")
 
	Call ObjToolbrItem.SetBitmaps(BMPlocation & "Line.BMP", BMPlocation & "Line.BMP")
 
 
 
	'Description for your own defined button
 
	Set ObjToolbrItem = ObjToolbr.AddToolbarButton(0, "Add Button", "Add Button Description", "Add Button command")
 
	Call ObjToolbrItem.SetBitmaps(BMPlocation & "buttonimage2.bmp", BMPlocation & "buttonimage3.BMP")
 
 
 
	'To run a VBA project from the button macro add ("-vbarun" & vbcr & "Projectname.dvb!Modulename") as macro name
 
 
 
	'Set the location of the toolbar acToolbarDockLeft, acToolbarDockRight , acToolbarDockTop , acToolbarDockFloating
 
	ObjToolbr.Dock acToolbarDockRight
 
 
 
	End Sub

Attachments:
FileDescriptionFile sizeDownloads
Download this file (CreateToolbar.zip)CreateToolbar.zipCreate AutoCad Toolbar6 Kb510
 

Comments   

 
0 #2 Guest 2012-01-30 20:45
is VB the same as VBA? :o
Quote
 
 
0 #1 Guest 2011-03-23 09:48
When you close autocad and reopen it looses the buttons. Does anyone know of this problem and a fix for it?
Quote
 

Add comment


Security code
Refresh

This site has been updated and renewed. You have followed an old link.

Click here to go to the new site

http://www.visiblevisual.com/jupgrade