Wednesday, June 17, 2009

A script to open, display and close a PDF file using QTP.

See main post here.

Below is just a simple example which shows how to open a PDF file, show it on the screen and close it. I have a PDF QTP_PAM.pdf in my c:\ drive.

Option Explicit
Dim accapp, acavdocu
Dim pdf_path
pdf_path = "C:\QTP_PAM.pdf"

'AcroExch.App is the Acrobat application; below we are initializing Acrobat by creating App object

Set accapp = CreateObject( "AcroExch.App" )

'show method shows the Acrobat application

accapp.Show()

'we have to create one AVDoc object per displayed document

Set acavdocu = CreateObject( "AcroExch.AVDoc" )

'open the PDF

acavdocu.Open pdf_path, "MyTitle"
wait 0, 200
accapp.CloseAllDocs()
accapp.Exit()
Set accapp = Nothing : Set acavdocu = Nothing