Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running AutoCAD from MS Excel 2

Status
Not open for further replies.

3576

Programmer
Jan 28, 2005
32
US
I am trying to run an AutoCAD application from an Excel spreadsheet which is generated by a VB application and I need to add an AutoCAD refences dynamically in MS Excel.
How can I do it?

Thanks,

TW
 
Hey, TW, I don't have answer for ya, but I think I'm looking for almost the same thing that you are! I am trying to create a front end in MS Access which will write a file (preferably text) with commands that can be input into Autocad to draw objects.
It looks like forms and VB can be coded within AutoCad; however, I need to be able to specify my parameters (line commands) in my Access app
I'm a COBOL mainframer by trade; therefore, I am a beginning beginner w/autocad.
Please put a post here if you find out how to do this by other means of this site.
thanx....Rusty
 
Here is a code that will allow you to open a drawing and manipulate a block from MS Access:

1) Add an object library reference. Open any module and Select Tools -> References - > AutoCAD 2000 Type Library (ACAD.TLB) file

Public acadApp As Object
Public acadDoc As AcadDocument

' This will open an AutoCAD application
Set acadApp = CreateObject("Autocad.Application")
Set acadDoc = acadApp.ActiveDocument
acadApp.Visible = True

'open a drawing that you want to manipulate
acadDoc.Open strDrawingName & strDrawingPath

'select an autocad block that you want to manipulate
Set acBlockRef = acadDoc.HandleToObject(strHandle)
'get all tag names and tag text
Let acSubMemberAttrib = acBlockRef.GetAttributes

'loop through all tags in a block
For j = LBound(acSubMemberAttrib) To UBound (acSubMemberAttrib)

Select Case acSubMemberAttrib(j).TagString

Case "CABLE_NUMBER"
'adds new value
acSubMemberAttrib(j).TextString = "New Value"

Case "DESTIN_SYSN1"
'extract value from the tag
strSysName = acSubMemberAttrib(j).TextString
End select

'save changes to the drawing
acadDoc.Save
'close application
acadApp.Application.Quit
Set acadApp = Nothing

Hope this helps. TW
 
Hi 3576,

Use this:

Code:
application.ActiveWorkbook.VBProject.References

HTH
Todd
 
Thank you TCARPENTER, that worked! TW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top