VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VB6.0 communication with AutoCAD

7 REPLIES 7
Reply
Message 1 of 8
sgrya1
678 Views, 7 Replies

VB6.0 communication with AutoCAD

Hi all.

Can someone please help me out with this problem.

I have spent a LONG time creating a VB6.0 application that sends a finished drawing to AutoCAD. Problem is that it only works with the version of AutoCAD (2007) I have on my computer. I assume that this is because the type library files that are loaded into the VB app are from my version.

When I've tried to install it on any other version (2000-2006 & 2008) the AutoCAD connection fails.

Are there universal type library files that are available?

I've read before that I need to use "Late Binding" which I think I'm already doing. This is what I have:

Dim AcadDoc As Object, AcadApp As Object

Sub OpenAutoCAD
On Error Resume Next
' *** set reference to AutoCAD Application
Set AcadApp = GetObject(, "AutoCAD.Application")
' *** if there is an error (AutoCAD not open) or it's in SDI mode create a new instance of AutoCAD
If Err Or AcadApp.Application.Preferences.System.SingleDocumentMode Then
' *** clear the error
Err.Clear
' *** create the new instance of AutoCAD
Set AcadApp = CreateObject("Autocad.Application")
' *** if there is another error give up
If Err Then
MsgBox "Cannot find AutoCAD"
'Hide the dialogue box
FrmWait.Hide
'Revert Mouse Pointer
Screen.MousePointer = vbDefault
Exit Sub
End If
' *** Make Autocad Visible
AcadApp.Visible = True
' *** Maximise Autocad
'AcadApp.Application.WindowState = acMax
' *** set reference to active document
Set AcadDoc = AcadApp.Application.Documents.Add(App.Path & "\acadiso.dwt")
Else ' *** If CAD is existing and in MDI mode create a new document
Set AcadDoc = AcadApp.Application.Documents.Add(App.Path & "\acadiso.dwt") ' you don't have to use a template name here
' *** Make Autocad Visible
AcadApp.Visible = True
' *** Maximise Autocad
AcadApp.Application.WindowState = acMax
End If
End Sub

Can anyone help me here?
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: sgrya1

From your code, it is difficult to say it is "Late Binding", the very same
code could be used for "Early binding", too. So, you have to tell what does
"only work on my computer" mean.

To make you code "Late binding", you should not set reference to Acad type
library at all in your VB project. Did you do so?


wrote in message news:5708599@discussion.autodesk.com...
Hi all.

Can someone please help me out with this problem.

I have spent a LONG time creating a VB6.0 application that sends a finished
drawing to AutoCAD. Problem is that it only works with the version of
AutoCAD (2007) I have on my computer. I assume that this is because the type
library files that are loaded into the VB app are from my version.

When I've tried to install it on any other version (2000-2006 & 2008) the
AutoCAD connection fails.

Are there universal type library files that are available?

I've read before that I need to use "Late Binding" which I think I'm already
doing. This is what I have:

Dim AcadDoc As Object, AcadApp As Object

Sub OpenAutoCAD
On Error Resume Next
' *** set reference to AutoCAD Application
Set AcadApp = GetObject(, "AutoCAD.Application")
' *** if there is an error (AutoCAD not open) or it's in SDI mode create
a new instance of AutoCAD
If Err Or AcadApp.Application.Preferences.System.SingleDocumentMode Then
' *** clear the error
Err.Clear
' *** create the new instance of AutoCAD
Set AcadApp = CreateObject("Autocad.Application")
' *** if there is another error give up
If Err Then
MsgBox "Cannot find AutoCAD"
'Hide the dialogue box
FrmWait.Hide
'Revert Mouse Pointer
Screen.MousePointer = vbDefault
Exit Sub
End If
' *** Make Autocad Visible
AcadApp.Visible = True
' *** Maximise Autocad
'AcadApp.Application.WindowState = acMax
' *** set reference to active document
Set AcadDoc = AcadApp.Application.Documents.Add(App.Path &
"\acadiso.dwt")
Else ' *** If CAD is existing and in MDI mode create a new document
Set AcadDoc = AcadApp.Application.Documents.Add(App.Path &
"\acadiso.dwt") ' you don't have to use a template name here
' *** Make Autocad Visible
AcadApp.Visible = True
' *** Maximise Autocad
AcadApp.Application.WindowState = acMax
End If
End Sub

Can anyone help me here?
Message 3 of 8
sgrya1
in reply to: sgrya1

Norman.

I'm not sure if anyone told be to remove the 2007 type library from VB6.0 before. I think thats the answer. Only problem is I'n now in an office where there's only 2007 full version and 2008 LT. So I don't know if thats the solution.

It's not working on the 2008 LT.
Errors are created on the lines
Set AcadApp = GetObject(, "AutoCAD.Application")
and
Set AcadApp = CreateObject("Autocad.Application")
So LT doesn't open.

Is there an alternative application name for LT versions of CAD?
Message 4 of 8
Anonymous
in reply to: sgrya1

LT versions do not expose an API.

joe ...

"sgrya1" wrote in message news:5708677@discussion.autodesk.com...
Norman.

I'm not sure if anyone told be to remove the 2007 type library from VB6.0
before. I think thats the answer. Only problem is I'n now in an office where
there's only 2007 full version and 2008 LT. So I don't know if thats the
solution.

It's not working on the 2008 LT.
Errors are created on the lines
Set AcadApp = GetObject(, "AutoCAD.Application")
and
Set AcadApp = CreateObject("Autocad.Application")
So LT doesn't open.

Is there an alternative application name for LT versions of CAD?
Message 5 of 8
sgrya1
in reply to: sgrya1

Explains things.

Thank you both.
Message 6 of 8
dolives
in reply to: sgrya1

Hi,
For other application :
The only this I find on internet !

Daniel OLIVES
FRANCE-Lyon

Select Case acadversion

Case "Autocad 14"
'initialisation DDE Autocad v.14
chan = DDEInitiate(App:="AutoCAD.r14.DDE", topic:="System")

Case "Autocad LT 2000-2008"
'initialisation DDE Autocad LT
chan = DDEInitiate(App:="AutoCAD LT.DDE", topic:="System")

Case "Autocad 2000-2002"
'initialisation DDE Autocad 2000, 2002 ou MAP
chan = DDEInitiate(App:="AutoCAD.r15.DDE", topic:="System")

Case "Autocad 2004-2006"
'initialisation DDE Autocad 2004, 2006 ou MAP
chan = DDEInitiate(App:="AutoCAD.r16.DDE", topic:="System")

Case "Autocad 2007-2008"
'initialisation DDE Autocad 2007, 2008 ou MAP
chan = DDEInitiate(App:="AutoCAD.R17.DDE", topic:="System")
End Select
Message 7 of 8
sgrya1
in reply to: sgrya1

THANKYOU!!!!.

Haven't tested it yet but even though I have removed the 2007 type library and have "late binding" for some reason it still only works with 2007.

Fingers crossed. It's a real drawback with my app at the moment.
Message 8 of 8
sgrya1
in reply to: sgrya1

Taken a while to get around to this..

How do I find out what autocad version is running on the computer that my application is running on?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost