在特定位置将范围保存为 pdf

Saving a range to pdf in a specific location

我需要在电子邮件中发送一系列单元格,但格式为 pdf 文件。现在我可以创建 pdf 并保存它,但是由于 excel 文件将在不同的计算机上使用,我现在无法找到文件的路径并以这种方式附加它。是否可以立即将范围作为 pdf 附加到电子邮件中?或者提示 window 以便用户选择他保存 pdf 的位置,然后我可以使用该路径将其附加到电子邮件中。 谢谢!

Application.Workbook().Path 应该能满足您的需求:

Dim FolderPath As String
FolderPath = Application.Workbook("name of book.xlsm").Path
'Use your save PDF macro to save to the FolderPath string
'Reference FolderPath in attachment to message.