VBAからAdobe ReaderでPDFファイルを印刷する。(その3)
Adobe Reader 7.0 ~ 8.1
Sub PdfPrint(ParamArray Files())
Dim wShell As Object
Dim Path As String
Dim pExec As Object
Dim k As Integer
Dim oExec As Object
Set wShell = CreateObject("WScript.Shell")
Path = wShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\acrord32.exe\")
Path = Replace(Path, """", "")
Path = wShell.ExpandEnvironmentStrings(Path)
Set pExec = wShell.Exec("""" & Path & """ /n /h""")
Do While Not wShell.AppActivate(pExec.ProcessID)
Application.Wait Now + TimeSerial(0, 0, 1)
Loop
For k = 0 To UBound(Files)
Set oExec = wShell.Exec("""" & Path & """ /n /t """ & Files(k) & """")
Do While oExec.Status = 0
Application.Wait Now + TimeSerial(0, 0, 1)
Loop
Next
If pExec.Status = 0 Then pExec.Terminate
End Sub
SendKeys()を使わないので、SendKeys()が嫌いな人向き。:-p
その代わり、ダミーのアプリを起こすので、その分、ちと重くなりますが。。。
« ZIP圧縮の待ち合わせ方法 | トップページ | VB.NETからAdobe ReaderでPDFファイルを印刷する。 »