
How To Fill In An HTML Form On A Web Page Using A Standalone .VBS Script
You access the web document through the browser's--wait for it--document
property! You can manipulate objects on the page just like you can using the
document object in client-side scripts.
Here a Q&D example the fills in a fictitious form and submits it:
Const URL = "http://localhost/flintstones.html"
With WScript.CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate URL
Do Until .ReadyState = 4
WScript.Sleep 50 ' wait for page to load
Loop
With .document.forms("bedrock")
.fred.value = "text" ' enter text into a textbox
.barney.selectedIndex = 2 ' select third option of a select
.wilma(1).checked = True ' select second of a group of radio buttons
.betty(0).checked = True ' check first
.betty(2).checked = True ' and third of a group of checkboxes
.submit
End With
End With
WARNING: You'll probably want a more rigorous test for the page's loading.
--
Experience is that marvelous thing that enables you to recognize a mistake when
you make it again. -Franklin P. Jones
=-=-=
Steve
-=-=-
I have been trying to figure out how to create a VBS
script that will allow me to launch Internet Explorer,
open a specific web page, and fill-in a form on the web
page.
I have gotten as far as launching Internet Explorer and
opening a specific web page with the following code:
[ snipped ]
And this is all for my code. So far I can do the basic of
getting this started; however, I can not seem to find a
way or an example of how to set the Internet Explorer
Document object to a local VBScript object so I can
manipulate elements (text boxes on the form) through use
of their IDs and VALUE property.
Has anyone done something like this or know of a source
where I can get information or examples of how this is
done???
My goal is to automate filling out various common work
orders that get submitted on my company's local intranet
through a web page. The only form fiels that really
changes with my common work orders is the description,
room number, and location for each work order. I figure I
can place the commands to create each common (monthly)
work order in VBS files and execute them as needed.