通过 VBA 将 MS Excel 2003 工作簿导出为 PDF

发布于 2024-07-07 20:57:28 字数 340 浏览 9 评论 0原文

我有一个 Excel 2003 工作簿,其中包含一个宏,用于将其某些工作表复制到新工作簿,然后保存并关闭新工作簿。 它会执行此操作数十次,每次选择的纸张都略有不同。

我想向宏添加一个额外的步骤,以将辅助工作簿的电子表格导出为 PDF。 最明显的方法是使用 PDF 打印机和 Excel 的内置打印功能,但大多数 PDF 打印机在完成之前都会显示“另存为...”对话框。 显然,在七十多个场合单独输入这个内容缺乏吸引力 - 所以我想要一些可以让我提前设置它的东西(可能是“使用我正在打印的文件的文件名减去其扩展名”),然后只需选择默认选项。

有什么想法可以制作一款免费的 PDF 打印机吗? 或者合适的替代方案?

I have an Excel 2003 workbook that contains a macro to copy certain of its sheets across to a new workbook, then save and close the new workbook. It does this several dozen times, with slightly different sheet selections each time.

I would like to add an extra step to the macro to export the secondary workbooks' spreadsheets to PDF. The obvious way to do this would be to use a PDF printer and Excel's built in Print function, but most PDF printers give you a "Save As..." dialogue box before they finish. Obviously, typing this in individually for seventy-odd occasions lacks appeal - so I'd like something that allows me to set it ahead of time (probably "Use the filename of the file I'm printing minus its extension") then just select the default options.

Any ideas for a free PDF printer that does this? Or a suitable alternative?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

戏舞 2024-07-14 20:57:28

Office 2007 允许这样做。 我发现 PDFCreator 很好,VBA 包含在示例文件中,并且听说CutePDF 也不错。 PDFCreator 和 CutePDF 是免费的。

Office 2007 allows for this. I have found PDFCreator to be good, the VBA is included in sample files, and have heard that CutePDF is also good. PDFCreator and CutePDF are free.

感性不性感 2024-07-14 20:57:28

作为 Remou 的(明智的)答案的发展,因为这也帮助我解决了我的问题。

我选择 pdfcreator (因为我已经安装了它),这就是我最终使用的:

Sub PDF_Print() 
    Dim p 
    p = ActivePrinter 
    ActivePrinter = "PDFCreator" 
    ActiveDocument.PrintOut 
    ActivePrinter = p 
End Sub 

Works像一个魅力

As a development on the (wise) answer from Remou, and since this was what helped me out on my problem too.

I choose pdfcreator (since I already had it installed) and this is what I ended up using:

Sub PDF_Print() 
    Dim p 
    p = ActivePrinter 
    ActivePrinter = "PDFCreator" 
    ActiveDocument.PrintOut 
    ActivePrinter = p 
End Sub 

Works like a charm

甜柠檬 2024-07-14 20:57:28

这可能会有所帮助: http://www.pdf995.com

一项功能是“绕过三个自动命名选项”另存为对话框”

This may help: http://www.pdf995.com

One feature is "Three auto-name options to bypass Save As dialog"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文