CarlStephens
Board Regular
- Joined
- Sep 25, 2020
- Messages
- 128
- Office Version
- 2016
- Platform
- Windows
Hello Team,
I currently have the below code that prints a sheet to pdf and saves it to the user's desktop and takes the file name from a cell and names the file, but I want to change it so that it does not save to the desktop automatically and simply opens the Save As dialog for the user to choose where to save the file. Can I kindly take a moment of someone's time to enlighten me on what change is required? Thank you in advance.
Sub PrintVisa()
Dim s As String, p As String
s = Range("N1").Value 'file name
p = Environ("USERPROFILE") & "\Desktop\"
If Right(p, 1) <> "\" Then p = p & "\"
If Dir(p, vbDirectory) = "" Then
MsgBox "The path does not exist"
Exit Sub
End If
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=p & s, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
MsgBox "Success - The file is now on your desktop, please move this file in the Visa Letters folder on One Drive by clicking cell P1. ", vbInformation
End Sub
I currently have the below code that prints a sheet to pdf and saves it to the user's desktop and takes the file name from a cell and names the file, but I want to change it so that it does not save to the desktop automatically and simply opens the Save As dialog for the user to choose where to save the file. Can I kindly take a moment of someone's time to enlighten me on what change is required? Thank you in advance.
Sub PrintVisa()
Dim s As String, p As String
s = Range("N1").Value 'file name
p = Environ("USERPROFILE") & "\Desktop\"
If Right(p, 1) <> "\" Then p = p & "\"
If Dir(p, vbDirectory) = "" Then
MsgBox "The path does not exist"
Exit Sub
End If
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=p & s, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
MsgBox "Success - The file is now on your desktop, please move this file in the Visa Letters folder on One Drive by clicking cell P1. ", vbInformation
End Sub