Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Opening PDF with VBScript

3,451 views
Skip to first unread message

SWK

unread,
May 24, 2001, 5:22:27 PM5/24/01
to
Hello folks!
Is there any way to open PDF files using VBScript?

thanks

Tom Lavedas

unread,
May 25, 2001, 9:18:50 AM5/25/01
to
In what context? A web application or a stand alone (*.vbs) script or
???

When the Adobe Reader is installed on a machine, there is a registered
ActiveX object available (though Adobe does not support it for user
scripts, AFAIK). Michael Harris advised several weeks ago that this
object requires a host container, like IE, to function. He gave this
example of printing a PDF document ...

-------------------------------------------------------------------
The Acrobat Reader has to be hosted in a container window like a VB form
or an IE window...

set ie = createobject("internetexplorer.application")
ie.navigate "about:blank"
do until ie.readystate = 4 : wscript.sleep 10 : loop
set doc = ie.document
set pdf = doc.createElement(_
"<object id='pdf' " _
& " classid='clsid:CA8A9780-280D-11CF-A24D-444553540000'>")
doc.body.appendChild(pdf)
do until ie.readystate = 4 : wscript.sleep 10 : loop
pdf.src = "C:\your path\your.pdf"
pdf.PrintAll
do until ie.readystate = 4 : wscript.sleep 10 : loop

--
Michael Harris
Microsoft.MVP.Scripting
-------------------------------------------------------------------

The essence of this approach can be used to create an instance of the
PDF object for use in a web application, though I haven't played with
it yet. A good object viewer would give you some insight into the
properties and methods available.

I have also used the Wscript.Shell Run method to simply START a PDF
document in order to 'open' it with a stand alone script, something like
this ...

CreateObject("Wscript.Shell").Run "start " & sPathspecToPDF

But, started this way the script has no control (unless you call
throwing keystrokes at it via Sendkeys control).

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/

Jonathan Shay

unread,
May 25, 2001, 9:22:00 AM5/25/01
to
Assuming the acrobat writer is installed, the following code should work:

Set ox = wscript.CreateObject("WScript.Shell")
ox.Run ("fullpathtofile.pdf")

"SWK" <BigSea...@yahoo.com> wrote in message
news:0e8901c0e497$a23a7ab0$b1e62ecf@tkmsftngxa04...

sk

unread,
May 29, 2001, 3:28:32 PM5/29/01
to
Hello folks,
I am trying to open pdf inside of IE and Nav using VBScript. has anyone used
Acrobat reader active x before?

thanks
sk

.

Jason Wilson

unread,
May 30, 2001, 4:07:32 PM5/30/01
to
Is all that really necessary. If the PDF plug-in is installed can't
you just create an IE object and navigate to the PDF?

Jason

"sk" <BigSea...@yahoo.com> wrote in message news:<072e01c0e875$8c1b7040$98e62ecf@tkmsftngxs05>...

0 new messages