Hi,
thanks for the prompt reply.
I tried using a portion of the program that you had given. I am opening a STEP file and saving it as a IPT file. But, at the following statement,
Call oSTEPTranslator.Open(oDataMedium, oContext, oOptions, oTarget)
I am getting an error quoting, "Method 'Open' of object '_IRxTranslatorAddIn' failed".
The following is the function that i am using,
Public Function pbcfncSTEPtoPART(strIptOutFolder As String, strPartName As String, strFilePath As String, oExcel As Object, i As Integer)
Debug.Print "Entering function pbcfncSTEPtoPART()"
' Find the STEP translator Add-In.
'Dim oSTEPTranslator As TranslatorAddIn
Dim oSTEPTranslator As Inventor.TranslatorAddIn
Dim g As Integer
For g = 1 To gobjInvApp.ApplicationAddIns.Count
If gobjInvApp.ApplicationAddIns.Item(g).ClassIdString = "{90AF7F40-0C01-11D5-8E83-0010B541CD80}" Then
Set oSTEPTranslator = gobjInvApp.ApplicationAddIns.Item(g)
Exit For
End If
Next
If oSTEPTranslator Is Nothing Then
MsgBox "Could not access STEP translator."
Exit Function
End If
Dim oContext As TranslationContext
Set oContext = gobjInvApp.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
Set oOptions = gobjInvApp.TransientObjects.CreateNameValueMap
Dim oDataMedium As DataMedium
Set oDataMedium = gobjInvApp.TransientObjects.CreateDataMedium
oDataMedium.fileName = strFilePath
If oSTEPTranslator.HasOpenOptions(oDataMedium, oContext, oOptions) Then
If oOptions.Count > 0 Then
Dim j As Long
For j = 1 To oOptions.Count
Debug.Print " " & oOptions.Name(j) & " = " & oOptions.Value(oOptions.Name(j))
Next
End If
oOptions.Value("EnableMultiLumpsAsAsm") = False
Dim oTarget As Object
Call oSTEPTranslator.Open(oDataMedium, oContext, oOptions, oTarget)
'Set odoc = gobjInvApp.Documents.OpenWithOptions(strFilePath, oOptions, True)
End If
Dim strStepFileName As String
Dim strStepFileName1 As String
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
strStepFileName = strIptOutFolder + "\" + strPartName + "x1" + ".ipt"
strStepFileName1 = strIptOutFolder + "\" + strPartName + ".ipt"
If objFSO.FileExists(strStepFileName) = True Then
Call objFSO.DeleteFile(strStepFileName)
End If
If objFSO.FileExists(strStepFileName1) = True Then
Call objFSO.DeleteFile(strStepFileName1)
End If
Dim objDocStep As Inventor.PartDocument
'Create ipt file
Set objDocStep = gobjInvApp.Documents.Item(strStepFileName1)
objDocStep.SaveAs strStepFileName, False
objDocStep.Close False
objFSO.MoveFile strStepFileName, strStepFileName1
oExcel.Columns("Q:Q").Select
oExcel.Selection.NumberFormat = "m/d/yyyy h:mm:ss"
oExcel.Cells(i, 17).Value = objFSO.GetFile(strStepFileName1).DateLastModified
Set objDocStep = Nothing
Set objFSO = Nothing
pbcfncSTEPtoPART = NO_ERR
Debug.Print "Exiting function pbcfncSTEPtoPART()"
Exit Function
ErrorHandler:
Set objDocStep = Nothing
Set objFSO = Nothing
Debug.Print "Exiting function pbcfncSTEPtoPART()"
Exit Function
End Function
Please let me know if you have any solution.