Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I've been trying to use underneath code to save all the .idw files in the same folder to pdf. It seems to work fine but it gives this error at the end: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Any help would be great! Thanks in advance.
Greets,
Frank
This is the code:
SyntaxEditor Code Snippet
'-----Check path----- oPath = ThisDoc.Path '-----get PDF target folder path----- oPDFFolder = Left(oPath, InStrRev(oPath, "\")) & "KSE" & "\" & "PDF" '-----Check for the pdf folder and create it if it does not exist----- If Not System.IO.Directory.Exists(oPDFFolder) Then System.IO.Directory.CreateDirectory(oPDFFolder) End If '-----Search for idw's in folder----- Dim MyFiles As String() MyFiles = System.IO.Directory.GetFiles(oPath, "*.idw") '-----Starts the Loop----- For Each MyFile As String In MyFiles ThisApplication.SilentOperation = True Dim partDoc As Document = ThisApplication.Documents.Open(MyFile, False) On Error Resume Next If partDoc.DocumentType = kDrawingDocumentObject Then Dim oPropSet As PropertySet Dim oProp As Inventor.Property Dim invPartNoProperty As Inventor.Property = partDoc. _ PropertySets.Item("Design Tracking Properties").Item("Part Number") PartNumber = invPartNoProperty.Value oRevNum = iProperties.Value("Project", "Revision Number") oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oRevNum = iProperties.Value("Project", "Revision Number") oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 1 'oOptions.Value("Custom_End_Sheet") = 4 End If '-----Filename definition----- oFileName = oPDFFolder & "\" & PartNumber & "r" & oRevNum & ".pdf" '-----Set the PDF target file name----- oDataMedium.FileName = oFileName '-----Publish document----- oPDFAddIn.SaveCopyAs(partDoc, oContext, oOptions, oDataMedium) End If partDoc.Close(False) partDoc = Nothing ThisApplication.SilentOperation = False Next '-----Opens PDF Folder----- Shell("explorer.exe " & oPDFFolder,vbNormalFocus)
---------------------------------------------------------------------------------------------------------
Solved! Go to Solution.