GetObject / CreateObject

GetObject / CreateObject

Anonymous
Not applicable
258 Views
4 Replies
Message 1 of 5

GetObject / CreateObject

Anonymous
Not applicable
I have a VB6 program. At the start of the program I check
to see if a session of AutoCAD is running.
Set myApp = GetObject(, "AutoCAD.Application")


The problem is that although AutoCAD is running, Err
is true and my program opens a new session of AutoCAD
If Err Then
Err.Clear
Set myApp = CreateObject("AutoCAD.Application")


I have AUTOCAD 14 running on Win NT.


Public Sub Main()
On Error Resume Next

Set myApp = GetObject(, "AutoCAD.Application")

If Err Then
Err.Clear
Set myApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
Set myDoc = myApp.ActiveDocument

End Sub
0 Likes
259 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
ehm... i thought the answer to this question is that you have to use
AutoCAD.Application.14
Did i win?

wkr, jkw
--
You ask a silly question, you get a technical answer...
Mal had the next bright idea:

>I have a VB6 program. At the start of the program I check

>to see if a session of AutoCAD is running.

>Set myApp = GetObject(, "AutoCAD.Application")

The problem is
>that although AutoCAD is running, Err
is true and my program opens
>a new session of AutoCAD
If Err Then

>    Err.Clear

>    Set myApp = CreateObject("AutoCAD.Application")
>

I have AUTOCAD 14 running on Win NT.

Public Sub Main()
>
On Error Resume Next

Set myApp = GetObject(,
>"AutoCAD.Application")

If Err Then

>    Err.Clear
    Set
>myApp = CreateObject("AutoCAD.Application")

>    If Err Then

>        MsgBox Err.Description
>
        Exit Sub

>    End If

>End If

>Set myDoc = myApp.ActiveDocument

End Sub


>

0 Likes
Message 3 of 5

Anonymous
Not applicable
Thanks for your input.
but akkkkkkkkk!!! no winner

On most of our systems just
"AutoCAD.Application"
works

but adding the 14 does not work on any of our systems.
"AutoCAD.Application.14"


stumped ????, I am !!

We also have LDDT and AutoCAD map on these systems.
0 Likes
Message 4 of 5

Anonymous
Not applicable
It is something in that direction. Unless someone else from the newsgroup
can tell you what the correct name is, you have to search in the registry
to find the correct description of AutoCAD.Applictation.Blablablah. If you
find the correct description for the systems with map and lddt (which is
probably the troublemaker), maybe you can code a construction like;

on error resume next
getobject with only application
do something
if that is not working, use application.14
do something
if that isn't working...

(this reply is probably more confusing than the previous... 🙂

wkr, jwk
Mal had the next bright idea:

>Thanks for your input.

>but akkkkkkkkk!!! no winner

On most of our systems just

>"AutoCAD.Application"

>works

but adding the 14 does not work on any of our systems.

>"AutoCAD.Application.14"

stumped ????, I am !!

We also have
>LDDT and AutoCAD map on these systems.

--
You ask a silly question, you get a technical answer...

0 Likes
Message 5 of 5

Anonymous
Not applicable
I think your code is working. look at the windows task manager and you will that the processus acad.exe is running

On Error Resume Next

Set myApp = GetObject(, "AutoCAD.Application")

If Err Then
Err.Clear
Set myApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
myApp .windowstate = acmax
myApp.ActiveDocument.windowstate=acmax
0 Likes