AutoCAD from VB, error type

Discussion in 'AutoCAD' started by alkimium, Sep 29, 2004.

  1. alkimium

    alkimium Guest

    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
     
    alkimium, Sep 29, 2004
    #1
  2. alkimium

    VBA Guest

    This would work much better for you.

    Public Function LoadAutoCAD(oApp As AcadApplication) As Boolean
    On Error Resume Next

    'try to get running instant of AutoCAD
    Set oApp = GetObject(, "AutoCAD.Application")

    If Err Then
    Err.Clear

    Set oApp = CreateObject("AutoCAD.Application")

    'exit function, no AutoCAD available
    If Err Then Exit Function
    End If

    'AutoCAD instant open, make it visible
    oApp.Visible = True
    'return True that AutoCAD was opened successfully
    LoadAutoCAD = True
    End Function

    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?
     
    VBA, Sep 29, 2004
    #2
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 (here). After that, you can post your question and our members will help you out.