Skip to main content
Participant
June 16, 2009
Answered

Printing PDF files from vbscript

  • June 16, 2009
  • 3 replies
  • 47682 views

I want to print some pdf files using a simple vbscript running on XP.   I tried this and it didn't work:

Set objAcroPDF = CreateObject("AcroPDF.PDF")
objAcroPDF.LoadFile("C:\D2\Scanner\test.pdf")
objAcroPDF.PrintAll

Set objAcroPDF = Nothing

I got the script from this website.

http://www.aspfree.com/c/a/Windows-Scripting/Printing-Documents-in-WSH/4/

But anyway, it doesn't work. Maybe it used to work and adobe changed
something or I am doing something wrong.

So my question is, how do I print pdf documents from vbscript. 
I have Acrobat 9 standard installed, and so will all the users of this script.

This is vbscript running on the client.

This topic has been closed for replies.
Correct answer ReinhardF

I ask google for "vbs+print+pdf". It presented 862 000 results.

Maybe now one is interested to increase this number.

Here a simple commondline solution.

set oWsh = CreateObject ("Wscript.Shell")

oWsh.run """Acrobat.exe"" /p /h" &FileName,,true

HTH, Reinhard

3 replies

Participant
July 20, 2015

My code has a "false" at the end, while yours has a "true"

set oWsh = CreateObject ("Wscript.Shell")

oWsh.run """Acrobat.exe"" /p /h" &FileName,,false

What's the difference?

tks

Legend
July 21, 2015

It is vital to choose that parameter right. Documentation on Wscript.Shell.run here: .Run | VBScript | SS64.com

June 18, 2009

One way of doing it is to use Acrobat's command line print options.

Here is the VBScript code for the same:

<<

Sub test()

    print_mypdf ("E:\test.pdf")

End Sub

Sub print_mypdf(MyFile As String)

    DoEvents

    Shell "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe /p /h " & MyFile, vbHide

End Sub

>>

This prints PDF to the default printer. Please see if this helps.

tcAtlantaAuthor
Participant
June 16, 2009

I am suprised that no one has responded.  I had this question in another forum and no one responded and a guy said to try in this forum.

Is there something real hard about this, or is it something that no one ever does?  It seems to me that lots of people would need to print out PDF docs from client side VBscript.  Am I in the wrong forum?  A guy in the acrobat scripting forum said to try here.

ReinhardF
ReinhardFCorrect answer
Participating Frequently
June 16, 2009

I ask google for "vbs+print+pdf". It presented 862 000 results.

Maybe now one is interested to increase this number.

Here a simple commondline solution.

set oWsh = CreateObject ("Wscript.Shell")

oWsh.run """Acrobat.exe"" /p /h" &FileName,,true

HTH, Reinhard

tcAtlantaAuthor
Participant
June 18, 2009

Answer # 2 works

set oWsh = CreateObject ("Wscript.Shell")

oWsh.run """Acrobat.exe"" /p /h" &FileName,,true

Answer # 3 might work in regular VB, but you can't do shell and doevents in vbscript.

Thanks Everyone