Need help with example getting text from HTMP

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Need help with example getting text from HTMP

Post by kpassaur » Mon Oct 17, 2005 2:40 pm

The example of posting data into an HTML form has a function that I think is to Extract Text (Table Text). I have been trying to get this to work and cannot. I have modified the origional script and can post data into different forms with no dificulty (just like the example shows). However, I would like to capture table text and I think the example should allow it. I have changed the page with a table to the download page for macro scheduler for trial. However, I am doing something wrong here and was hoping someone could look it over and show me what.




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

'This function extracts text from a specific tag by name and index
'e.g. TABLE,0 (1st Table element) or P,1 (2nd Paragraph element)
'set all to 1 to extract all HTML, 0 for only inside text without HTML
Function ExtractTag(TagName,Num,all)
dim t
set t = IE.document.getElementsbyTagname(Tagname)
if all=0 then
ExtractTag = t.Item(Num).outerHTML
else
ExtractTag = t.Item(Num).innerText
end if
End Function

VBEND

VBRun>CreateIE
VBRun>Navigate,http://www.mjtnet.com/downloads.htm?ref=msfullwc74004
Wait>1
VBEVAL>ExtractTag,TABLE,0,1,tabledatareturned
MDL>%tabledatareturned%

Ask>All done - shall I close IE now?,r
If>r=YES
VBRun>KillIE
endif


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