Jump to content

vbscript open webpage, submit form, close


Recommended Posts

Anyone have code to do this?

 

I found this code, but for some reason it's not getting/submitting the form properly

 

Set IE = CreateObject("InternetExplorer.Application")
set WshShell = WScript.CreateObject("WScript.Shell")
IE.Navigate "http://www.somewebsite.com/form.php"
IE.Visible = True
Wscript.Sleep 2000
call IE.Document.Forms(3).Submit()

 

It is the 4th form on the page, but i get the following error:

Object doesn't support this property or method 'IE.Document.Forms(...).Submit'

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/215452-vbscript-open-webpage-submit-form-close/
Share on other sites

got it to work now. Not sure why but I had to make a slight change to the last line of code in order for the form to be submitted properly:

 

call IE.Document.Forms("formName").elements("Submit").click

 

Now all I need to figure out how to close the IE window after it's done. How do I do that?

ok, sorry for bugging you guys. I figured out how to close the IE window after it was finished. Here's the final code:

 

'Create IE obect
Set IE = CreateObject("InternetExplorer.Application")
set WshShell = WScript.CreateObject("WScript.Shell")

'Go to webstie
IE.Navigate "http://www.somewebsite.com/form.php"
IE.Visible = True
Wscript.Sleep 2000

'Submit form
call IE.Document.Forms("formName").elements("Submit").click
Wscript.Sleep 2000

'Close IE
objIE.Quit
Set objIE = Nothing

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.