简体   繁体   English

使用 VBA 打印外部 Excel 文件

[英]Print External Excel File Using VBA

I Have a Excel File Which I have 5 Tabs, Say "Attachment".我有一个 Excel 文件,其中有 5 个选项卡,请说“附件”。

And I have another Excel which I am Working, Say "Request".我还有另一个正在工作的 Excel,比如说“请求”。

So I need Quick Print One of those excel from that "Attachment" in "Request" using VBA.所以我需要使用 VBA 从“请求”中的“附件”中快速打印其中一个。

Please Help!请帮忙!

But I saw some of them showing how to print a PDF (Not Working For Me).但是我看到其中一些展示了如何打印 PDF(不适合我)。

Sub Test()

PrintFile ("C:\Test.pdf")

End Sub 

This is the code if there is a pdf available to print and it is working with VBA这是代码,如果有可打印的 pdf 并且它正在使用 VBA

-Opens the specified pdf and prints it using the default printer - 打开指定的pdf并使用默认打印机打印

-Note that it uses the default PDF program and leaves it open - 请注意,它使用默认的 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 for the file location文件位置的strPth

strFile for the document name文档名称的strFile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM