Sub SaveAsPDF() Dim doc As Document Dim pdfPath As String Dim fileName As String Dim saveDirectory As String Dim dialog As FileDialog ' Set the document object Set doc = ActiveDocument ' Define the default directory for saving PDFs (modify this path) saveDirectory = "C:\Users\devpr\OneDrive\Documents\job2025\resumes" ' Change this to your preferred folder ' Check if the document is saved If doc.Path = "" Then ' If unsaved, ask for a filename Set dialog = Application.FileDialog(msoFileDialogSaveAs) With dialog .Title = "Save PDF As" .InitialFileName = saveDirectory & "New_Document.pdf" .FilterIndex = 2 .Filters.Clear .Filters.Add "PDF Files", "*.pdf" If .Show = -1 Then fileName = .SelectedItems(1) ' Corrected line Else Exit Sub ' User canceled End If End With Else ' If already saved, use the current file name (without extension) fileName = Left(doc.Name, InStrRev(doc.Name, ".") - 1) fileName = saveDirectory & fileName & ".pdf" End If ' Save as PDF using explicit numeric value for PDF format (17) doc.ExportAsFixedFormat OutputFileName:=fileName, _ ExportFormat:=17 ' 17 represents PDF export format ' Notify user MsgBox "File saved as PDF: " & fileName, vbInformation, "Success" End Sub