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.
Function CadOpen()
Dim CadApp As AcadApplication
Dim CadDwg As AcadDocument
Dim sDwg As String
'<><><><><><><><><><><><><><><><><><><><><>
' Connect to AutoCAD
'<><><><><><><><><><><><><><><><><><><><><>
On Error Resume Next
Set CadApp = GetObject(, "AutoCAD.Application"
If Err.Number <> 0 Then 'Not Running
Set CadApp = CreateObject("AutoCAD.Application"
Err.Clear
End If
'On Error GoTo ErrHndlr
'<><><><><><><><><><><><><><><><><><><><><>
' Open the Drawing Template
'<><><><><><><><><><><><><><><><><><><><><>
sDwg = "C:\YourDrawing.dwg"
If Dir(sDwg) <> "" Then
CadApp.Documents.Open sDwg
Else
MsgBox "File " & sDwg & " does not exist."
'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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.