Hello Everyone-
I am trying to find a way to close out of an IE window that my VBScript opened. Here is basically my code so far:
Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Visible = True
objExplorer.ToolBar = False
objExplorer.StatusBar = False
objExplorer.Navigate "about:blank"
objExplorer.Document.Body.InnerHTML = "<p>Assist Complete. <i>(You may now close this window.)</i></p><p><BUTTON TYPE=BUTTON NAME=""Close"" onClick=""window.close()"">Close </BUTTON></p>"
Do While TypeName(objExplorer) = "IWebBrowser2"
WScript.Sleep 1000
Loop
WScript.Echo "More code follows after the window is closed"
So I just need to find a good way to close the window. Does anyone have any suggestions? Like is there a way to assign a normal ?sub/method? to the Close button in my window? So that when the user clicks on the button it runs that code. If I could do that then I could just have my VBScript use SendKeys to send a ALT+F4 to close the window.
Or am I looking at this the complete wrong way? Any help would be appreciated.
Thanks!
-Mark
P.S. As you can see above in my code, I tried to attach the Window.Close() to the Close button. The reason this doesn't work right is because it prompts the user if they want to close the window. I just want it to close, no questions asked.
I am trying to find a way to close out of an IE window that my VBScript opened. Here is basically my code so far:
Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Visible = True
objExplorer.ToolBar = False
objExplorer.StatusBar = False
objExplorer.Navigate "about:blank"
objExplorer.Document.Body.InnerHTML = "<p>Assist Complete. <i>(You may now close this window.)</i></p><p><BUTTON TYPE=BUTTON NAME=""Close"" onClick=""window.close()"">Close </BUTTON></p>"
Do While TypeName(objExplorer) = "IWebBrowser2"
WScript.Sleep 1000
Loop
WScript.Echo "More code follows after the window is closed"
So I just need to find a good way to close the window. Does anyone have any suggestions? Like is there a way to assign a normal ?sub/method? to the Close button in my window? So that when the user clicks on the button it runs that code. If I could do that then I could just have my VBScript use SendKeys to send a ALT+F4 to close the window.
Or am I looking at this the complete wrong way? Any help would be appreciated.
Thanks!
-Mark
P.S. As you can see above in my code, I tried to attach the Window.Close() to the Close button. The reason this doesn't work right is because it prompts the user if they want to close the window. I just want it to close, no questions asked.