Message 1 of 2
AutoCAD from VB, error type

Not applicable
09-29-2004
09:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello..
I want to develop an application that runs inside AutoCAD, but i want to launch this application from an icon in Windows desktop. this icon would launch AutoCAD and my application, that is a VB Form. I've found this code for launch autoCAD in VB6, but it doesn't work. When i execute the program i get an error "Unknown type". I've reference the Autocad Common Libray file. But it seems to be needed another file, which file i've to reference?
This is the code i've found:
Public Sub Connect(Optional AcVisiblity As Boolean = True)
'Establish a connection to Autocad, Create one
'if none exists
Dim oAcadApp As acadapplication
Dim i As Integer: i = 0
On Error Resume Next
Set oAcadApp = GetObject(, "AutoCAD.Application.15")
If Err Then
Err.Clear
Restart:
Set oAcadApp = CreateObject("AutoCAD.Application.15")
If Err.Number = 91 Then
Err.Clear
If i = 3 Then
Exit Sub
Else
GoTo Restart
i = i + 1
End If
Else
Err.Clear
End If
End If
'Set the Visibility option
oAcadApp.Visible = AcVisiblity
'Raise Event when connection is first completed
RaiseEvent ConnectionOpened
End Sub
I want to develop an application that runs inside AutoCAD, but i want to launch this application from an icon in Windows desktop. this icon would launch AutoCAD and my application, that is a VB Form. I've found this code for launch autoCAD in VB6, but it doesn't work. When i execute the program i get an error "Unknown type". I've reference the Autocad Common Libray file. But it seems to be needed another file, which file i've to reference?
This is the code i've found:
Public Sub Connect(Optional AcVisiblity As Boolean = True)
'Establish a connection to Autocad, Create one
'if none exists
Dim oAcadApp As acadapplication
Dim i As Integer: i = 0
On Error Resume Next
Set oAcadApp = GetObject(, "AutoCAD.Application.15")
If Err Then
Err.Clear
Restart:
Set oAcadApp = CreateObject("AutoCAD.Application.15")
If Err.Number = 91 Then
Err.Clear
If i = 3 Then
Exit Sub
Else
GoTo Restart
i = i + 1
End If
Else
Err.Clear
End If
End If
'Set the Visibility option
oAcadApp.Visible = AcVisiblity
'Raise Event when connection is first completed
RaiseEvent ConnectionOpened
End Sub