将PDF自动保存到预定的文件夹

我正在写一个macros,使我每天发送的每日报告自动化。 我最后的一个项目是编写一个脚本,将格式化的Excel表格保存为PDF(通过打印到PDF选项),并将其保存在特定的文件夹中。 我有以下书面,但是,它仍然提示用户在哪里保存它。

将它自动保存到我的桌面上的某个文件夹,更好的方法或一般方法是什么?

Sub printToPDF() Worksheets("general_report").PageSetup.CenterVertically = False ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:="Foxit Reader PDF Printer" End Sub 

这应该做的工作,

 Sub printToPDF() Dim FilePath As String Dim FileName As String FilePath = "C:\Users\userName\Desktop\" 'Change as per your username ActiveSheet.Copy 'Copy a worksheet to a new workbook 'It saves .PDF file at your Descrop with the name of the worksheet ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, FileName:=FilePath & ActiveSheet.Name, _ Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _ OpenAfterPublish:=False 'Closing a newly created workbook without saving it Application.DisplayAlerts = False ActiveWorkbook.Close End Sub