Open Design Alliance Drawings SDK в Excel VBA

Я не очень хорошо знаком с VBA, только доступ к базе данных. Но мне было поручено обновить приложение для рисования САПР, написанное на Excel VBA, с использованием последней версии Open Designs Drawing SDK.

Он по-прежнему работает с предыдущей версией библиотеки TeighaX. Но когда я ссылаюсь на более новую версию библиотеки TeighaX, она не работает. Пример одной из функций ниже.

      Function funOpen_CAD_File(File_To_Open As Range, OpenDrawing As IAcadDocument, Optional Message As String) As Boolean
'
'Opens a CAD file. funOpen_CAD_File = True if the file opened OK
'
'Argument 1 = A single cell range containing the full path and name for the file to be opened
'Argument 2 = The IAcadDocument variable to open the drawing into
'Message = An optional text string that returns the document type and or erroe message
'
'If the CAD file cannot be opened, the range (Argument 1) is coloured Orange
'
'Other file types are coloured also.
'
'

    Dim sFilename As String
    Dim nErrorCellColourIndex As Integer
    Dim nNonDWGFileCellColour As Integer
    Dim objTeighaHost As TeighaX.OdaHostApp
    Dim objTeighaApp As TeighaX.AcadApplication
    
    funOpen_CAD_File = True
    sFilename = File_To_Open
    nErrorCellColourIndex = 3
    File_To_Open.Interior.ColorIndex = xlNone
    Message = "File OK"
    
    If LCase(Right(sFilename, 4)) = ".dwg" Then
            
            Set objTeighaHost = CreateObject("TeighaX.OdaHostApp")
'            Set objHost = New OdaHostApp
            Set objTeighaApp = objTeighaHost.Application

        
                'Some drawings can be broken - Check for this
                On Error GoTo ErrorTrap
                    Set OpenDrawing = objTeighaApp.Documents.Open(sFilename, False)
                On Error GoTo 0
                    
            objTeighaApp.Quit
            Set objTeighaApp = Nothing
            Set objTeighaHost = Nothing
            
            
    Else
    
        funOpen_CAD_File = False
        
        Select Case LCase(Right(sFilename, 4))
            
            Case ".xls", "xlsx", "xlsm"
                Message = "Excel File"
                File_To_Open.Interior.ColorIndex = 22
                
            Case ".doc", "docx", "docm"
                Message = "Word Document"
                File_To_Open.Interior.ColorIndex = 44
                
            Case ".pdf"
                Message = "PDF Document"
                File_To_Open.Interior.ColorIndex = 8
                
            Case ".jpg", ".bmp", ".tif"
                Message = "Image File"
                File_To_Open.Interior.ColorIndex = 36
            
            
            Case Else: Message = "Not a CAD File"
                Message = "Undefined Doc Type"
                File_To_Open.Interior.ColorIndex = 15
            
        End Select
        
    
    End If
    
    
    
Exit Function

ErrorTrap:

    funOpen_CAD_File = False
    File_To_Open.Interior.ColorIndex = nErrorCellColourIndex
    Message = "Faulty File - " & Err.Description
    Resume Next

End Function

Ошибки:

      Run-Time error '429':
ActiveX component can't create object

и

      License information for this component not found. You do not have an appropriate license to use this functionality in the design environment.

0 ответов

Другие вопросы по тегам