用水印副本打印PDF

时间:2015-05-27 09:19:04

标签: vba pdf printing word-vba

我想要使用水印副本打印几个外部PDF。见图: Printing pdf

所以我尝试使用下面的代码从word中打印pdf,但是没有任何内容可以打印,知道如何实现这个任务吗?

    Public Enum actionType
    openfile
    printfile
End Enum



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

Function ExecuteFile(fileName As String, action As actionType)
' action can be either "Openfile" or "Printfile".

Dim sAction As String

  Select Case action
    Case 0 ' openfile
      sAction = "Open"
    Case 1 ' printfile
      sAction = "Print"
  End Select

  ShellExecute 0, sAction, fileName, vbNullString, "", SW_SHOWNORMAL
End Function

Sub TestPrint()
  ' open a file
  'ExecuteFile "C:\MyFile.xls", openfile
  ' print another
  ExecuteFile "Z:\Prosjekt\32982\Tegninger\PDF\0081606.pdf", printfile
End Sub

0 个答案:

没有答案