Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all
Can someone please help me out
I have the following code but would like to have the Revision Number added to the end of PDF file name only if the revision number is 1 or above
Our Company likes to add the revision numbers to the end of PDF files after the 1st Rev (which is Rev 0)
SyntaxEditor Code Snippet
Dim oDoc As Inventor.Document For Each oDoc In ThisApplication.Documents.VisibleDocuments If (oDoc.documenttype = kDrawingDocumentObject) Then 'Found a drawing 'find the postion of the last backslash in the path oFNamePos = InStrRev(oDoc.fullfileName, "\", -1) 'get the file name with the file extension oName = Right(oDoc.fullfileName, Len(oDoc.fullfileName) - oFNamePos) 'get the path of the folder containing the file oPath = Left(oDoc.fullfileName, Len(oDoc.fullfileName) - Len(oName)) 'get the file name (without extension) oShortName = Left(oName, Len(oName) - 4) oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then 'oOptions.Value("All_Color_AS_Black") = 0 'oOptions.Value("Remove_Line_Weights") = 0 oOptions.Value("Vector_Resolution") = 600 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 End If 'get PDF target folder path oFolder = oPath & "\PDF" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oShortName & ".pdf" On Error Goto handlePDFLock 'Publish document oPDFAddIn.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium) End If Next oDoc 'Show message box MessageBox.Show("PDF(s) exported to: " & oFolder , "iLogic") '-------------------------------------------------------------------------------- Exit Sub handlePDFLock:MessageBox.Show("At least one PDF could not be saved, " _ & "most likely someone else has it open.", _ "No PDF for you " & ThisApplication.GeneralOptions.UserName & "!") Resume Next
Cheers
Donald
Solved! Go to Solution.