Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issue in Opening AutoCAD 2014 programmatically in VB 6.0

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
329 Views, 3 Replies

Issue in Opening AutoCAD 2014 programmatically in VB 6.0

Issue : we couldn’t invoke AutoCAD 2014 from our server by using visual basic programming.

 

The same program(code) can invoke AutoCAD 2000i without any issues.

 

We will receive an error message like “ActiveX component can’t create an object”, when we try to open AutoCAD from Visual basic 6.0 program.

 

We are using the following code for open AutoCAD.

 

Public Sub ConnectToAutoCad()

    On Error Resume Next

 

    Set Acad = GetObject(, AUTOCAD_VERSION)

    If Err Then

        Err.Clear

            Set Acad = CreateObject(AUTOCAD_VERSION)

            Sleep (2000)

        If Err Then

            MsgBox Err.Description

            Exit Sub

        End If

    End If

 

    Acad.Application.Visible = True

 

End Sub

 

 

Operating system : windows server 2003

AutoCAD :AutoCAD 2014 with 32 bit

Visual basic 6.0 is used to invoke the autocad 2014 .

 

Please help me to resolve this issue ASAP.

3 REPLIES 3
Message 2 of 4
ToddRogers-WPM
in reply to: Anonymous

You have AutoCAD installed on the server and you're trying to open it from a workstation?

Todd Rogers
Message 3 of 4
Anonymous
in reply to: ToddRogers-WPM

No. we are access the AutoCAD from the server itself. We don't have any issue in opening AutoCAD 2014 manually in server. But opening the AutoCAD 2014 through programmatically has an issue.

Message 4 of 4
Anonymous
in reply to: Anonymous

Did this ever get resolved ? I am upgrading a project that worked in Acad 2010 with very similar code. .  The error message talkes about an invalid cast of object type 

System.__ComObject

I have this code working on a test virtual machine running in my development environment. That machine is a 32bit workstation. The final location will be on a 64 bit 2008 R2 SP1 server

 

 Public Sub New(ByVal strAcadVersion As String)
 
        Try
            If Len(strAcadVersion) > 0 Then
                _AcadVersion = strAcadVersion
            End If
            'get existing 2007
            _App = GetActiveObject(_AcadVersion)
            _AppStarted = True
        Catch
            Try
                'create 2007
                _App = CreateObject(_AcadVersion)
                'set started flag
                _AppStarted = True
 
            Catch ex As Exception
                _AppStarted = False
 
                HandledExceptionManager.ShowDialog( _
                    "Error Creating AcadApp", _
                    "Autocad control will not take place", _
                    "Verify that the correct version of Autocad is being used", _
                    ex, , , , True)
                Throw ex
            End Try
        End Try
 
        _PrintersAvailable = GetPC3Files()
 
    End Sub
*************************************************************************************************************
The error message I am returned is :

Log Name: Application
Source: PDFPublisher.exe
Date: 9/26/2014 3:38:34 PM
Event ID: 0
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: Meridian2
Description:

What happened:
Error Creating AcadApp

How this will affect the user:
Autocad control will not take place

What the user can do about it:
Verify that the correct version of Autocad is being used

More information:
Detailed technical information follows:
---
Date and Time: 9/26/2014 3:38:34 PM
Machine Name: MERIDIAN2
IP Address: 131.243.130.76
Current User: Mzwijacz

Application Domain: PDFPublisher.exe
Assembly Codebase: file:///C:/Program Files (x86)/CDS/PDFPublisher/PDFPublisher.exe
Assembly Full Name: PDFPublisher, Version=2013.0.0.2, Culture=neutral, PublicKeyToken=null
Assembly Version: 2013.0.0.2
Assembly Build Date: 9/26/2014 12:37:16 PM

Exception Source: CDS.AppControler
Exception Type: System.InvalidCastException
Exception Message: Unable to cast COM object of type 'System.__ComObject' to interface type 'Autodesk.AutoCAD.Interop.AcadApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{7558007D-8677-4FF1-BD48-B66281BD3DD7}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Exception Target Site: .ctor

---- Stack Trace ----
CDS.AppControler.AcadApp..ctor(strAcadVersion As String)
AcadApp.vb: line 0314, col 17, IL 0151




 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost