【发布时间】:2020-03-16 07:30:07
【问题描述】:
我需要使用 excel VBA 打印 *.pdf 文件的选定页面。 我需要做到这一点不是通过提供范围“从 - 到”,而是提供像“1-3,4,8,17-25”这样的页面范围
我只能使用以下代码打印整个文件:
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Public Function PrintThisDoc(formname As Long, FileName As String)
On Error Resume Next
Dim X As Long
X = ShellExecute(formname, "Print", FileName, 0&, 0&, 3)
End Function
Sub testPrint()
Dim printThis
Dim strDir As String
Dim strFile As String
strDir = "C:\Users\any\Desktop"
strFile = "somefile.pdf"
printThis = PrintThisDoc(0, strDir & "\" & strFile)
End Sub ```
【问题讨论】:
-
很遗憾没有。我不需要将工作表打印为 pdf。我需要使用 excel VBA 从现有的 pdf 文件中打印特定页面。