Excel VBA打印外部文件

时间:2016-11-09 14:27:46

标签: excel excel-2010

我在执行Google搜索时找到了此代码。它似乎打开文本文件就好了,但我想打印文件。任何人都可以看到这里缺少什么,并告诉我为什么它不打印?感谢

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

Declare Function apiFindWindow Lib "User32" Alias "FindWindowA" _
   (ByVal lpclassname As Any, ByVal lpCaption As Any) As Long

Global Const SW_SHOWNORMAL = 1

Sub ShellExecuteExample()
   Dim hwnd
   Dim StartDoc
   hwnd = apiFindWindow("OPUSAPP", "0")

   StartDoc = ShellExecute(hwnd, "print", "C:\Scripts\print.vba.test.txt", "", _
      "C:\", SW_SHOWNORMAL)
End Sub

0 个答案:

没有答案