Error in variable: Automate forms in IE

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
gitest
Newbie
Posts: 7
Joined: Fri May 13, 2005 2:40 pm

Error in variable: Automate forms in IE

Post by gitest » Wed Jul 20, 2005 8:21 pm

Hi,

if you run this script

VBSTART
Dim IE

Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub

Sub Navigate(URL)
IE.Navigate URL
do while IE.Busy
loop
End Sub

Sub KillIE
IE.Quit
Set IE = nothing
End Sub

Sub WebFormFill(fieldname,fieldvalue,submit)
Dim FormNr
Dim ItemNr
Dim TheForm

if IE.Document.All.Tags("FORM").Length = 0 then
MsgBox("No form found in page")
else
for FormNr = 0 to IE.Document.Forms.Length - 1
Set TheForm = IE.Document.Forms(FormNr)
for ItemNr = 0 to TheForm.Elements.Length - 1
if TheForm.Elements(ItemNr).Name = fieldname then
TheForm.Elements(ItemNr).Value = fieldvalue
If submit=1 then
TheForm.submit
end if
exit for
end if
next
next
end if
End Sub

VBEND

VBRun>CreateIE
VBRun>Navigate,http://www.mjtnet.com/contact.htm
Wait>1
Let>name=Marcus
Let>email=[email protected]
VBRun>WebFormFill,name,%name%,0
VBRun>WebFormFill,email,%email%,0

there is no problem until Version 7.3.10.4.

After Version 7.3.10.5 you will see no entries.

Solution: Change the variable names:
Let>var_name=Marcus
Let>var_email=[email protected]
VBRun>WebFormFill,name,%var_name%,0
VBRun>WebFormFill,email,%var_email%,0

The variable names must be different from the names in the form!!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts