|
-
Dec 10th, 2009, 04:56 PM
#1
Thread Starter
New Member
[RESOLVED] How to capture a Acrobat PDF window closing event in VB6?
Hi,
I am trying to develop a normal window form that user can click on the PDF filename and Acrobat opens up the PDF file, then when the user clicks "X" on the PDF window, I want to capture that event before the window actually closes and pops the user if he wants to save the file to the local drive.
Here is the code that I use to open up the PDF file, which works perfect:
Dim appAcrobat As AcroApp
Dim docAcrobat As AcroAVDoc
Set appAcrobat = CreateObject("AcroExch.App")
appAcrobat.Show
Set docAcrobat = CreateObject("AcroExch.AVDoc")
docAcrobat.Open sFullFileName, sFileName
But I don't know how to capture any of the events related to the PDF window via appAcrobat or docAcrobat object, since I can not even use "WithEvents" keyword when I delcare them, that way the compiler throws an error saying: "object does not source automation events."
By the way, I am referencing Adobe Acrobat 7.0 Type Library.
So I come here for some ideas. Any advice will be appreaciated.
Thanks!
-
Dec 10th, 2009, 05:17 PM
#2
Re: How to capture a Acrobat PDF window closing event in VB6?
rather than that... what you could do... is create a new form, put the webbrowser control on it... then instead of launching Acrobat, just use the webbrowser to .Navigate2() and pass it the full file location of the PDF. Since the WebBrowser control is essentially what IE uses, the PDF should open up right inside it, just like it would with a full browser... then on the Unload or QueryUnload event of your form, which would be completely under your control, then you could ask the user if they want to save it, then take appropriate action as necessary.
But this is theory, not sure if it would actually work. Seems like it should though.
-tg
-
Dec 10th, 2009, 05:48 PM
#3
Thread Starter
New Member
Re: How to capture a Acrobat PDF window closing event in VB6?
Thanks for the suggestion!
But where to get the web browser control? I am using VB6.
 Originally Posted by techgnome
rather than that... what you could do... is create a new form, put the webbrowser control on it... then instead of launching Acrobat, just use the webbrowser to .Navigate2() and pass it the full file location of the PDF. Since the WebBrowser control is essentially what IE uses, the PDF should open up right inside it, just like it would with a full browser... then on the Unload or QueryUnload event of your form, which would be completely under your control, then you could ask the user if they want to save it, then take appropriate action as necessary.
But this is theory, not sure if it would actually work. Seems like it should though.
-tg
-
Dec 10th, 2009, 06:04 PM
#4
Re: How to capture a Acrobat PDF window closing event in VB6?
Open up the dialog where you can add components to your toolbox.... it's in there somewhere... I forget the exact name. it is NOT the Microsoft Internet Control (MSINET) ... If I remember right, it specificalyl says "Web browser" in its name.
-tg
-
Dec 10th, 2009, 06:59 PM
#5
Thread Starter
New Member
Re: How to capture a Acrobat PDF window closing event in VB6?
I found it and added it to the toolbox. Thanks!
Will post again after I tried the method you suggested.
 Originally Posted by techgnome
Open up the dialog where you can add components to your toolbox.... it's in there somewhere... I forget the exact name. it is NOT the Microsoft Internet Control (MSINET) ... If I remember right, it specificalyl says "Web browser" in its name.
-tg
-
Dec 11th, 2009, 05:20 PM
#6
Thread Starter
New Member
Re: How to capture a Acrobat PDF window closing event in VB6?
The webbrowser strategy works. I can easily manage the window closing event through the form events.
Just in case someone else interested, to add the webbrowser component to your toolbox, right-click on the toolbox tab on the left-hand-side of your IDE window, then click "components..."; In the pop up window, select "Microsoft Internet Controls" in the "Component" tab, then click apply and ok. Then goto Project->References, check "Microsoft Internet Controls" to add it to your references, this way you can use the "SHDocVw.InternetExporer" object as well.
-
Dec 11th, 2009, 05:22 PM
#7
Re: How to capture a Acrobat PDF window closing event in VB6?
Sweet! If this is now resolved, could you mark it so? (this way if some one else comes looking for a similar problem, they know there's an answer here.) You can do that by using the Thread Tools up at the top.
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|