Sub Main () '-----Inital User Input ----- '-----User defined Scope----- Dim UserChoice = InputRadioBox("What files do you want to export", "Only This Open Document", "All Open Documents", True, Title := "Defined the scope") '-----User question setup ----- Dim UserSelectedActionList = New String(){"PDF & DWG", "PDF Only", "DWG Only"} '-----User question input ----- Dim UserSelectedAction As String = InputListBox("What Format is Required ?", UserSelectedActionList, UserSelectedActionList(0), Title := "File Type to Export", ListName := "File Format Type") If UserChoice = True Then 'UserChoice will be True is first option is selected oDoc = ThisApplication.ActiveEditDocument Call ExportFile(oDoc, UserSelectedAction) '----- Single File Success Message----- Select Case UserSelectedAction Case "PDF & DWG" MessageBox.Show(" File successfully exported to PDF & DWG. ", "Export Complete") Case "PDF Only" MessageBox.Show(" File successfully exported to PDF. ", "Export Complete") Case "DWG Only" MessageBox.Show(" File successfully exported to DWG. ", "Export Complete") End Select Else For Each openDocument As Document In ThisApplication.Documents.VisibleDocuments If openDocument.DocumentType = kDrawingDocumentObject Then Try If Len(openDocument.File.FullFileName) >0 Then Call ExportFile(openDocument, UserSelectedAction) End If Catch End Try End If Next '----- Multi File Success Message ----- Select Case UserSelectedAction Case "PDF & DWG" MessageBox.Show(" All files successfully exported to PDF & DWG. ", "Export Complete") Case "PDF Only" MessageBox.Show(" All files successfully exported to PDF. ", "Export Complete") Case "DWG Only" MessageBox.Show(" All files successfully exported to DWG. ", "Export Complete") End Select End If End Sub Sub ExportFile(ByRef oDocument As Document, UserSelectedOption As String) '-----Check path----- oPath = ThisDoc.Path '-----Get Target folder paths----- oPDFFolder = oPath & "\#Auto PDFs\" oDWGFolder = oPath & "\#Auto DWGs\" '-----Check for the folder paths and create it if they do not exist----- If Not System.IO.Directory.Exists(oPDFFolder) Then System.IO.Directory.CreateDirectory(oPDFFolder) End If If Not System.IO.Directory.Exists(oDWGFolder) Then System.IO.Directory.CreateDirectory(oDWGFolder) End If '----- Fill Variables ----- oFullFileName = oDocument.File.FullFileName oPath = Left(oFullFileName, InStrRev(oFullFileName, "\") -1) oFileName = Right(oFullFileName, Len(oFullFileName) -InStrRev(oFullFileName, "\")) oFilePart = Left(oFileName, InStrRev(oFileName, ".") -1) '-----Load PDF Add In----- 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 '-----PDF options ----- If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then 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 End If '----- Sets the appened Revision Number text----- If oDocument.PropertySets.Item("Inventor User Defined Properties").Item("09 REVISION").Value = "" Then oRevString = "_(REV MISSING)" ElseIf oDocument.PropertySets.Item("Inventor User Defined Properties").Item("09 REVISION").Value = "AB" Then oRevString = "_" & oDocument.PropertySets.Item("Inventor User Defined Properties").Item("09 REVISION").Value & " (AS BUILT)" Else oRevString = "_rev" & oDocument.PropertySets.Item("Inventor User Defined Properties").Item("09 REVISION").Value & "" End If '-----Set the PDF target file name----- oDataMedium.FileName = oPDFFolder & "\" & oFilePart & oRevString & ".pdf" '-----Export User Selection----- Select Case UserSelectedOption Case "PDF & DWG" 'Export PDF oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) 'Export DWG oDocument.SaveAs(oDWGFolder & "\" & oFilePart & oRevString & ".dwg", True) Case "PDF Only" 'Export PDF oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) Case "DWG Only" 'Export DWG oDocument.SaveAs(oDWGFolder & "\" & oFilePart & oRevString & ".dwg", True) End Select End Sub