TheSwamp

Code Red => VB(A) => Topic started by: robplatt on April 05, 2007, 07:18:47 AM

Title: Accessing AutoCAD from other Program
Post by: robplatt on April 05, 2007, 07:18:47 AM
Hi all,
Í've successfully sent stuff from ACAD to Excel and Access, and now i'm trying to do the reverse - ie. access ACAD from Excel using VBA.
I have cobbled together a routine that seems to work, but it needs the line:
    Set acadApp = GetObject(, "AutoCAD.Application.16")
I understand all of this except the reference to "16". I gather this is a version reference (I'm using 2006), but where can I find what number to use for other versions?
Your comments greatfully received as always!
Title: Re: Accessing AutoCAD from other Program
Post by: Glenn R on April 05, 2007, 08:13:00 AM
Registry.
Title: Re: Accessing AutoCAD from other Program
Post by: Keith™ on April 05, 2007, 11:15:55 AM
If you don't bother with the version, it will find the current application loaded regardless of version.

i.e.
Code: [Select]
Set acadApp = GetObject(, "AutoCAD.Application")
Title: Re: Accessing AutoCAD from other Program
Post by: Dnereb on April 10, 2007, 12:35:53 PM
If you want to bother with versions some stations have multiple Acad versions installed, you need to use diffrent code for diffrent versions etc.... this might help you out, it's written for several apps.
Title: Re: Accessing AutoCAD from other Program
Post by: robplatt on April 25, 2007, 06:26:24 AM
Thanks Dnereb,
I think I'll probably need something like this.
Title: Re: Accessing AutoCAD from other Program
Post by: ML on April 26, 2007, 11:30:07 AM

As Keith mentioned, if you need to be version specific, just type in the version as shown below

Code: [Select]
Set ACADApp = GetObject(, "AutoCAD.Application.16.2")

Mark
Title: Re: Accessing AutoCAD from other Program
Post by: ML on May 11, 2007, 10:23:14 AM

Hey Rob,

Going back to your original question, if you need the specific version of ACAD  that you are using, you can use a very simple macro like

Code: [Select]
Sub Version()
MsgBox Application.Version
End Sub

The message box will return the version for you

Mark