Open AutoCad drawing from Access

E

Erik Svensson

Hi
I am trying to create a drawing database for our AutoCAD drawings and I want
to create a button that opens up a specific drawing when it is found by a
search query. When I try to have this VBA code the error message "Microsoft
Office Access can't find the field 'Open type' referred to in your
expression". I have checked in the control panel and the .dwg ending is
assigned to AutoCAD. Can anyone help me with this problem?

Private Sub Command43_Click()
On Error GoTo Err_Command43_Click

Dim stAppNameSTANDARD As String
Dim stAppNameCUSTOM As String

stAppNameSTANDARD = "G:\data\DRAWINGS\F600000-F609999 STANDARD PANELS\"
& Forms![Drawing search form]![Open drawing]

stAppNameCUSTOM = "G:\data\DRAWINGS\F680000-F689999\" & Forms![Drawing
search form]![Open drawing]

If Forms![Drawing search form]![Open type] = "STANDARD" Then
Application.FollowHyperlink (stAppNameSTANDARD)

If Forms![Drawing search form]![Open type] = "CUSTOM" Then
Application.FollowHyperlink (stAppNameCUSTOM)

Exit_Command43_Click:
Exit Sub

Err_Command43_Click:
MsgBox Err.Description
Resume Exit_Command43_Click

End Sub


Thanks
/Erik Svensson
 
A

aaron.kempf

hey I would start with 'never using spaces in either form names, field
names, control names; etc'

hope that helps; i've definitely found some problems with spaces;
sometimes you've got to use underscores; and it's just a big pain if
you use spaces in object names anywhere
 
N

Norman Yuan

You should use ActiveX automation to start AutoCAD. Try followig code
(Assume AutoCAD is installed, the code is not tested):

1. Set reference to AutoCAD Type library in Access VBA IDE,
2. Add code to the CommandButton_Click() procedure:

Dim acad As AutoCAD.AcadApplication
Dim dwg As AutoCAD.AcadDocument

Set acad=New AutoCAD.AcadApplication
acad.Visible=True

Set dwg=acad.Documents.Open("C:\Drawing folder\your drawing file name.dwg")

''Do anything you want to this opened drawing

dwg.Close False 'Or "True" if you want to save changes
acad.Quit

Of course you may want to add some error habdling coed.
 
R

Ron2006

I am not sure of the significanse of the difference, but

the example for followhyperlink given in the help does NOT have the
link string in ()


Application.FollowHyperlink strInput

And I have used space in strings and have not had problems with the
followhyperlink.

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top