Printing/Quitting when Controlling IE

D

D

I'm trying to write something that will launch Internet Explorer, go to a
specified webpage, print said webpage, and then quit IE. Since you
apparently cannot access any commands when controlling IE, such as printing,
saving, etc., I have used sendkeys to launch the print dialog, which is fine,
I want the user to be able to select the printer to print to, print settings,
etc. The problem I'm having is trying to close out IE afterwards. The
ie.Quit command isn't working because it doesn't know to wait until the print
dialog is closed, presumably. It doesn't even know it's open, since I'm just
using sendkeys. Is there some event I could use, perhaps, to wait until the
print dialog has been closed before running ie.quit, or anything similar.
Any ideas? I tried various Do Until Loops, to try and quit once the
statusbar no longer says "Done", or was now blank, etc., but couldn't get
anything to work. Any help would be great.

Public Sub adsf()
dim ie as InternetExplorer
dim wsh as Object

Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate ("http://www.google.com")
Do Until ie.readystate = READYSTATE_COMPLETE And Not ie.Busy
Loop
Set wsh = CreateOjbect("WScript.Shell")
wsh.sendkeys ("^p")

ie.Quit
Set ie = Nothing
Set wsh = Nothing
End Sub
 
D

DA

Hi D

Have you tried to place a DoEvents before the quit?
Alternatively you could also try and check the Tasks list
to see if the spooler is active.

Best of luck,
Dennis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top