Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Closing an open PDF
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
What ise wrong with: **

Code:
Set AcroAVDoc = CreateObject( "AcroExch.AVDoc" )

' Open the PDF
If AcroAVDoc.Open( gPDFPath, "" ) Then
        If AcroAVDoc.IsValid = False Then ExitTest()
        AcroAVDoc.BringToFront()
        Call AcroAVDoc.Maximize( True )
        Set AcroPDDoc = AcroAVDoc.GetPDDoc()
        PDFName = AcroPDDoc.GetFileName()
        PDFPageCount = AcroPDDoc.GetNumPages()
End If

'** NONE OF THE BELOW CLOSE THE PDF

Code:
AVDoc.CloseAllDocs()  
AVDoc.Exit()          
                      
AcroAVDoc.CloseAllDocs(
AcroAVDoc.Exit()      
                        
AcroExch.CloseAllDocs()
AcroExch.Exit()  
      
Set AcroApp = Nothing
Set AcroAVDoc = Nothing


WHAT AM I DOING WRONG? (I think I made a mess of this)
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi,
Please see the corrected code below
Code:
Set AcroApp = CreateObject( "AcroExch.App" )
Set AcroAVDoc = CreateObject( "AcroExch.AVDoc" )
gPDFPath="C:\test.pdf" 'please change the path before execution
' Open the PDF
AcroApp.Show()
AcroApp.Maximize(vbMaximize)
If AcroAVDoc.Open(gPDFPath,"") Then
If AcroAVDoc.IsValid = False Then ExitTest()
AcroAVDoc.BringToFront()
Call AcroAVDoc.Maximize( True )
Set AcroPDDoc = AcroAVDoc.GetPDDoc()
PDFName = AcroPDDoc.GetFileName()
PDFPageCount = AcroPDDoc.GetNumPages()
'msgbox PDFName
'msgbox PDFPageCount
AcroApp.CloseAllDocs()
AcroApp.Exit()
End If
Set AcroApp = Nothing
Set AcroAvDoc = Nothing

Regards,
Ravi
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
Tax again Ravi


but how do i then close my file? What i am trying wont close my open PDF.

thx
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
The lines below should close the file
Code:
AcroApp.Hide()
AcroApp.CloseAllDocs()
AcroApp.Exit()
or for cross verification you may check the returnvalue
Code:
AcroApp.Hide()
returnValue1 = AcroApp.CloseAllDocs()  'returnValue= -1 if successful,0 if not
returnValue2 = AcroApp.Exit()
msgbox returnValue1
msgbox returnValue2
Note: AcroApp.Exit() Returns -1(or true) if the entire shutdown process succeeded. This includes closing any open
documents, releasing OLE references, and finally exiting the application. If any step fails,
the function returns 0, and the application will continue running. This method will not
work if the application is visible (if the user is in control of the application). In such
cases, if the Show() method had previously been called, you may call Hide() and then
Exit().
Please let me know your findings.If this doesn't help..please let me know whether or not there is an error message, if so, what it is?

Regards,
Ravi
Reply
#5
Solved: 11 Years, 3 Months, 4 Weeks ago
Ravi...

Thx this worked perfectly. I had no error message, i just could not get my PDF to close. I think my earlier code was incorrect.

Your the best, THX
Reply
#6
Solved: 11 Years, 3 Months, 4 Weeks ago
Glad it worked.Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SAP GUI gets hanged while closing the Windows Pop Up kathirvelnagaraj 0 5,535 10-23-2015, 06:47 PM
Last Post: kathirvelnagaraj
  When QTP is open am not able to open my AUT. chetan3987 2 3,113 02-12-2014, 01:18 AM
Last Post: supputuri
  recovery scenario for closing a message box itself ashima 0 2,241 12-26-2013, 11:10 AM
Last Post: ashima
  closing browser at end bistritapcv 3 6,211 04-12-2013, 07:21 AM
Last Post: basanth27
  closing the browser diya 3 3,615 11-27-2012, 10:14 PM
Last Post: diya

Forum Jump:


Users browsing this thread: 1 Guest(s)