Call To AcroExch.App In VB Script Fails
-
I found a VBScript years ago that will print only the first page of multiple PDF files. You just drag the PDF's over the shortcut to the script and it works...
'//Print first page of pdfs set WshShell = CreateObject ("Wscript.Shell") set fs = CreateObject("Scripting.FileSystemObject") Set objArgs = WScript.Arguments if objArgs.Count < 1 then msgbox("Please drag a file on the script") WScript.quit end if Set gApp = CreateObject("AcroExch.App") gApp.show '<- comment or take out to work in hidden mod 'open via Avdoc and print for i=0 to objArgs.Count - 1 FileIn = ObjArgs(i) Set AVDoc = CreateObject("AcroExch.AVDoc") If AVDoc.Open(FileIn, "") Then Set PDDoc = AVDoc.GetPDDoc() Set JSO = PDDoc.GetJSObject jso.print false, 0, 0, true gApp.CloseAllDocs end if next gApp.hide : gApp.exit : Quit() MsgBox "Done!" Sub Quit Set JSO = Nothing : Set PDDoc = Nothing : Set gApp =Nothing : Wscript.quit End Sub
This script has worked through Windows 7, 10, 11 and multiple versions of Adobe Acrobat.
Now, the script will not work and it shows this:
Line 25 is this:
Set AVDoc = CreateObject("AcroExch.AVDoc")
So here's the troubleshooting I've done so far before I focused on line 25:Removed print drivers and reinstalled as either WSD, full drivers and generic drivers (all HP's)
Tried to uninstall recent Windows 11 Updates but it immediatley reinstalls it on reboot.
Ran the script on a Windows 10 machine with a much older copy of Adobe Acrobat and it works.So I am guessing it has something to do with recently updated versions of Acrobat...which is 2023.006.20320.
So, is this related to recent Adobe Acrobat updates and if so, is there another command to use to "call" Acrobat?
-
For now, I removed the newest Acrobat and reloaded a perpetual 2017 version and it is working again. Clearly something in the last Acrobat Update or maybe a combo of it with Windows Update.