VBA 打印为 PDF
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14254099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA Print as PDF
提问by Sid
How do I save as PDF an Excel Print File automatically without Asking for Filename or showing the adobe reader.
如何在不询问文件名或显示 adobe reader 的情况下自动将 Excel 打印文件另存为 PDF。
This is for automated email with attachments.
这是用于带有附件的自动电子邮件。
I dont need Excel Necessarily as I will use Outlook VBA to retrieve records then align it, excel, crystal rep, save it as PDF and attach.
我不需要 Excel,因为我将使用 Outlook VBA 来检索记录,然后将其对齐、excel、水晶代表,将其另存为 PDF 并附加。
回答by Timur Aykut YILDIRIM
I don't know how your document looks like so it might not quiet cut it but you can save every worksheet of your document as pdf file like this:
我不知道您的文档是什么样子,所以它可能不会安静地剪切它,但您可以将文档的每个工作表保存为 pdf 文件,如下所示:
Sub Mac()
Dim wsh As Worksheet, vWshs, vWshName
vWshs = Array("Sheet1", "Sheet2", "Sheet3")
With ActiveWorkbook
For Each vWshName In vWshs
.Worksheets(vWshName).ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Tmp\" & vWshName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Next vWshName
End With
End Sub