Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open AutoCad 1

Status
Not open for further replies.

ryan1

Programmer
May 15, 2002
106
US
Having a bit of a problem. I want to be able to open AutoCad and a Drawing from Access. Then store the path of the drawing in a table so later i can re open the same drawing without having to go through the network path because the path is stored in a table.
 
sButler,

Most of this info is from this site

Here the code to open cad

Function CadOpen()
Dim CadApp As AcadApplication
Dim CadDwg As AcadDocument
Dim sDwg As String

'<><><><><><><><><><><><><><><><><><><><><>
' Connect to AutoCAD
'<><><><><><><><><><><><><><><><><><><><><>
On Error Resume Next
Set CadApp = GetObject(, &quot;AutoCAD.Application&quot;)
If Err.Number <> 0 Then 'Not Running
Set CadApp = CreateObject(&quot;AutoCAD.Application&quot;)
Err.Clear
End If
'On Error GoTo ErrHndlr

'<><><><><><><><><><><><><><><><><><><><><>
' Open the Drawing Template
'<><><><><><><><><><><><><><><><><><><><><>
sDwg = &quot;C:\YourDrawing.dwg&quot;
If Dir(sDwg) <> &quot;&quot; Then
CadApp.Documents.Open sDwg
Else
MsgBox &quot;File &quot; & sDwg & &quot; does not exist.&quot;
'Handle the problem?
Exit Function
End If
Set CadDwg = CadApp.ActiveDocument

Set CadDwg = Nothing
Set CadApp = Nothing
End Function


Your going to have to make it visible. Search this site.


Your also going to need a browse button. The best one I found is at this site. (It's used to pick a folder)I wrote a loop to import a couple hundred drawings at one time.


If you want to pick a specific file use the browse code written by Ken Getz. Search this site.

then just write it to a table (This part isn't a complete piece of code)



rst.AddNew
rst.Fields(&quot;Diagram&quot;) = Dir(sDwg)
rst.Fields(&quot;Location&quot;) = sLoc

You can set up your form to show the drawing and the location. add a button to open or double click.

If you don't like the open code use the wizard in access, create a button, select open application, set acad path, etc..


I hope this helps you get started.



Praxden
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top