首页 > 解决方案 > 使用 VBA 打印外部 Excel 文件

问题描述

我有一个 Excel 文件,其中有 5 个选项卡,说“附件”。

我还有另一个正在工作的 Excel,说“请求”。

因此,我需要使用 VBA 从“请求”中的“附件”中快速打印其中一个 excel。

请帮忙!

但我看到其中一些展示了如何打印 PDF(不适合我)。

Sub Test()

PrintFile ("C:\Test.pdf")

End Sub 

标签: excelvbaprinting

解决方案


如果有可打印的 pdf 并且它正在与 VBA 一起使用,这是代码

- 打开指定的 pdf 并使用默认打印机打印

- 请注意,它使用默认的 PDF 程序并保持打开状态

Sub PrintChecklistExcav_Backfill()


Dim strPth As String, strFile As String

strPth = "C:\File"
strFile = "name of document.pdf"

If Not PrintPDF(0, strPth & strFile) Then
    MsgBox "Printing failed"
End If

End Sub

文件位置的strPth

strFile为文档名称


推荐阅读