Sub SaveAsPDF()
Dim invoiceNo As String
Dim customerName As String
Dim fname As String
Dim Path As String
' Get invoice number and customer name from specific cells
invoiceNo = Range("F6").Value
customerName = Range("B10").Value
' Construct file name
fname = invoiceNo & " - " & customerName
' Specify file path
Path = "C:\Users\TAHA\Documents\YT\Short\"
' Check if the specified path exists
If Dir(Path, vbDirectory) = "" Then
MsgBox "The specified path does not exist.", vbExclamation
Exit Sub
End If
' Export active sheet as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
ignoreprintareas:=False, _
fileName:=Path & fname
' Display confirmation message
MsgBox "PDF file saved successfully.", vbInformation
End Sub