Help needed Opening dwg from VB6 in A2K

Help needed Opening dwg from VB6 in A2K

Anonymous
Not applicable
223 Views
4 Replies
Message 1 of 5

Help needed Opening dwg from VB6 in A2K

Anonymous
Not applicable
I am starting to learn VB6 for Acad2000 and have some experience in VB.

Please could somebody help me how can I open a particular drawing from
VB6 in Autocad2000,
including all References, Dim's I have to do.

Thank you in advance
--
Val Iliev
valentin@canada.com
0 Likes
224 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Be sure to include a reference to the AutoCAD 2000 object type library in
your project. Place a command button on your form and double-click it. Use
this code as a guide:

Dim acadApp as AcadApplication

On Error Resume Next
Set acadApp = GetObject(,"AutoCAD.Application")
If err then set acadApp = CreateObject("AutoCAD.Application")
If err then
msgbox "Couldn't connect to AutoCAD!", vbCritical
end
else
acadApp.Documents.Open
end if

Of course you'd probably want to use a dialog to get the file from a user
but the method remains the same.

Val Iliev wrote in message
news:38074978.622085F1@berg-group.com...
> I am starting to learn VB6 for Acad2000 and have some experience in VB.
>
> Please could somebody help me how can I open a particular drawing from
> VB6 in Autocad2000,
> including all References, Dim's I have to do.
>
> Thank you in advance
> --
> Val Iliev
> valentin@canada.com
>
>
0 Likes
Message 3 of 5

Anonymous
Not applicable
Hi Frank

Thank you for your help, but this is what happens when I ran the code.

1.It opens drawing name - Drawing1.dwg in the App.Path where VB6.EXE is.

2.The Error Message you specified comes up.

Any suggestions?

Thank you

--
Val Iliev
valentin@canada.com
0 Likes
Message 4 of 5

Anonymous
Not applicable
Oops. In the first if statement, I forgot to clear the error object.
This ->If err then set acadApp = CreateObject("AutoCAD.Application")
Should be this:
If err then
err.clear
set acadApp = CreateObject("AutoCAD.Application")
end if

Also, it would be best to delcare the acadApp variable in the declarations
section of your form so you can keep a reference to the AutoCAD object for
the life of your app.

Val Iliev wrote in message
news:380756E9.CE557DCC@berg-group.com...
> Hi Frank
>
> Thank you for your help, but this is what happens when I ran the code.
>
> 1.It opens drawing name - Drawing1.dwg in the App.Path where VB6.EXE is.
>
> 2.The Error Message you specified comes up.
>
> Any suggestions?
>
> Thank you
>
> --
> Val Iliev
> valentin@canada.com
>
>
0 Likes
Message 5 of 5

Anonymous
Not applicable
Thank you Frank
It works fine now, opens the drawing and ..Crash!.."Unhendled Exemption
in fffff......."
What I've been getting so often recently.
We had A2K installed 3 weeks ago.

Thank you again for your help

--
Val Iliev
valentin@canada.com
0 Likes