Sub Main Try ' Reference the current document Dim doc As Document = ThisDoc.Document ' Check if the document is a DrawingDocument (IDW) If doc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then Dim drawingDoc As DrawingDocument = doc ' Set print settings for PDF export Dim printSettings As PrintSettings = drawingDoc.PrintSettings printSettings.PrintRange = PrintRangeEnum.kPrintAllSheets ' Prompt the user to choose a folder and file name Dim saveFileDialog As New System.Windows.Forms.SaveFileDialog() saveFileDialog.Filter = "PDF files (*.pdf)|*.pdf" saveFileDialog.Title = "Save PDF As" ' Show the save file dialog Dim result As System.Windows.Forms.DialogResult result = saveFileDialog.ShowDialog() ' Check if the user selected a file location If result = System.Windows.Forms.DialogResult.OK Then Dim pdfFilePath As String = saveFileDialog.FileName ' Export the IDW as a PDF drawingDoc.SaveAs(pdfFilePath, True) ' Inform the user MsgBox("PDF saved successfully at: " & pdfFilePath, MsgBoxStyle.Information, "PDF Saved") Else MsgBox("No file location selected. PDF not saved.", MsgBoxStyle.Information, "PDF Not Saved") End If Else ' Inform the user if the document is not an IDW MsgBox("The current document is not an IDW. PDF cannot be saved.", MsgBoxStyle.Exclamation, "PDF Not Saved") End If Catch ex As Exception ' Handle any exceptions MsgBox("An error occurred while saving the PDF: " & ex.Message, MsgBoxStyle.Critical, "Error") End Try End Sub