Search code examples
printingvbscriptadobeactivexacrobat

ADOBE VBS Script setup / settings


I have a nice and tidy VBS script which print first 5 pages off all documents which was dragged to this VBS.

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
    'contact Acrobat
Set gApp = CreateObject("AcroExch.App")
gApp.show 'comment or take out to work in hidden mode

  'open via Avdoc and print
for i=0 to objArgs.Count - 5
    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

My questions is regarding the settings.

I would like to know how to set up that this VBS will print first 6 pages as double sided, and so on. Is it somewhere there is a list of available settings?


Solution

  • Deniiiis, -- if you change:

    "for i=0 to objArgs.Count - 5" (which don't print the last 4 files) to

    for i=0 to objArgs.Count - 1
    

    and "jso.print false, 0, 0, true" (which only print the first page) to

    jso.print false, 0, 4, true
    

    then the script will do what you assumed.

    If you want to print double sided you have to use the js print parameter pageHandling. "Multiple Pages Per Sheet is obtained by setting pageHandling to nUp." You have to decide if you want to use "nUpNumPagesH" for a horinzontal lay out or "nUpNumPagesV" for a vertical - or both.

    An example and explanations you find here (under nUpNumPagesH): http://help.adobe.com/livedocs/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?href=JS_API_AcroJS.88.981.html&accessible=true

    The example is written in Acro-js code. You have to transform to jso (JavaScript Object) in VBS, then the script should do what you want.

    If you need some more help for that, don't hesitate to ask, Reinhard

    PS: By time you could read a little bit in the Acro JS help file / JS API reference for the statements you use :-)