将多张表格保存到.pdf [英] Save multiple sheets to .pdf

查看:231
本文介绍了将多张表格保存到.pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个报告电子表格,从数据库中获取一些数据,并形成三页摘要报告信息。我想从命令行自动运行电子表格,并自动将所有三个报表单保存为PDF文件。

I have a reporting spreadsheet that grabs some data from a database and forms three sheets of summary report information. I want to run the spreadsheet automatically from the command line, and have it automatically save all three reporting sheets as a PDF file(s).

起初我以为我可以在表上有一个VBA宏,通过一系列打印为PDF,但这需要一个中间的交互式对话框来指定输出文件名。然后我发现我可以保存为pdf,宏可以设置输出文件名。
然而,这会创建三个单独的文件,然后我必须将它们放在一起外部合并。

At first I thought I could have a VBA macro on the sheet do this by a series of "print as PDF", but that requires an intermediary interactive dialog box to specify the output file name. Then I find that I can just save as pdf, and the macro can set the output file name. However this creates three separate files, and I have to then later put them together externally to merge them.

(保存为pdf仅保存是奇怪的一个表格,其他保存模式似乎可以保存整个工作簿。)

(It is odd that save as pdf only saves one sheet, where other save modes seem to save the entire workbook.)

是的,有些工具可以稍后合并这三个文件,但是我想知道是否有一些简单的方法可以让Excel将多张表一起保存为一个pdf文件。

Yes, there are tools for merging the three files later, but I want to know if there is some easy way to get Excel to save multiple sheets together as one pdf file.

我现在打印一系列的东西,如:

I print now by a series of things like:

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, ...

我可以做一个单一的语句(伪代码):

Could I do instead a single statement something like (pseudo-code):

ThisWorkbook.Sheets(1,2,3,4).ExportAsFixedFormat Type:=xlTypePDF, ...


推荐答案

首先选择要组合的工作表:

Start by selecting the sheets you want to combine:

ThisWorkbook.Sheets(Array("Sheet1", "Sheet2")).Select

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\tempo.pdf", Quality:= xlQualityStandard, IncludeDocProperties:=True, _
     IgnorePrintAreas:=False, OpenAfterPublish:=True

这篇关于将多张表格保存到.pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆