• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Printing PDF files from vbscript

New Here ,
Jun 16, 2009 Jun 16, 2009

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript

Views

43.8K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Jun 16, 2009 Jun 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

Likes

Translate

Translate
New Here ,
Jun 16, 2009 Jun 16, 2009

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 16, 2009 Jun 16, 2009

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2009 Jun 18, 2009

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 18, 2012 Dec 18, 2012

Copy link to clipboard

Copied

Is there a way to close Acrobat in vbs?  When I run the script it prints the first file perfectly, but the issue is I would like it to print a whole lot of different documents.  When I manually close the program the next file will print, but the goal is automate the whole process.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 24, 2013 Jan 24, 2013

Copy link to clipboard

Copied

I had to kill the Adobe Reader Process between each print so the printer could reset to the next default, ie...

Sub KillAdobe()    

     set wmi = getobject("winmgmts:")    

     wmiq = "select * from Win32_Process where name='AcroRd32.exe'"    

     set qresult = wmi.execQuery(wmiq)    

     for each process in qresult      

          process.terminate(1)    

     next    

     Set wmi=nothing    

     Set wmiq=nothing    

     set qresult=nothing

End Sub

Then call the function, ie KillAdobe()

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 17, 2009 Jun 17, 2009

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 20, 2015 Jul 20, 2015

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 21, 2015 Jul 21, 2015

Copy link to clipboard

Copied

LATEST

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines