PDA

View Full Version : Solved: how do I close other app with vba



dmat619
11-17-2008, 03:57 PM
Hi,
I am working with vba in excel 2003 and have the following problem. I need to open internet explorer and then latter I need to close it. I can open it with:

Public Sub OpenInetExplorer()
ActiveWorkbook.FollowHyperlink "http://www.google.com (http://www.google.com/)"
End Sub

But I have not been able to find a way to close it useing vba.
Can anyone help, please?
Thanks,
dmat619

MaximS
11-17-2008, 05:09 PM
try this:


Sub Demo()

Dim ie As Object

Set ie = CreateObject("InternetExplorer.Application")

ie.navigate "http://www.google.com/"

Do While ie.busy And Not ie.readystate = 4

DoEvents

Loop

ie.Visible = True

Application.Wait Now + TimeSerial(0, 0, 5)

ie.Quit

Set ie = Nothing

End Sub



this should close IE windows

ie.Quit

dmat619
11-18-2008, 09:47 AM
Thanks MaximS,

That worked perfect. I was afraid I would have to use API calls. Your solution was both simple and easily understandable.

Thanks again,
dmat619