Hello,
I am attempting to write a script in vbs which will search a website for a phrase, then select or mouse click the phrase, then send TAB to move down to a hyperlink and download a file.
The reason I want to do this, is I have a web archive with constantly updating documents, I want to automatically download the latest document, and the newest hyperlink is always directly below the title phrase "AM FMI Weekly Report". If the script can select the title phrase, and then TAB down, then click the hyperlink, it will ensure I always download the latest document, without ever knowing the filename. Make sense?
Here is the code I have so far, I can search for the Title "AM FMI Weekly Report", but then how do I select or highlight this title, and tab down?:
set ie = Createobject("internetexplorer.application")
Set WshShell = WScript.CreateObject("WScript.Shell")
ie.visible = TRUE
ie.navigate2("
section_id=50882&prod_id=17690")
Do Until IE.Busy = FALSE
WScript.Sleep 10
Loop
If WshShell.AppActivate("SSO login for SupportCentral - Microsoft Internet Explorer") =
TRUE Then
Set theForm = IE.document.Forms(1)
ie.document.login.USER.value="username"
ie.document.login.PASSWORD.value="password"
ie.document.login.submit()
End If
WScript.Sleep 5000
If WshShell.AppActivate("Security Alert") = TRUE Then
WshShell.AppActivate("Security Alert")
WScript.Sleep 10
WshShell.SendKeys "Y"
End If
Do Until IE.Busy = FALSE
WScript.Sleep 10
Loop
Set oHTML = ie.Document
For Each oElement In oHTML.getElementsByTagName("*")
If oElement.innerText = "AM FMI Weekly Report" THEN
oElement.select???
WshShell.SendKeys "{TAB}"
oElement.click
Exit For
End If
Next
I am attempting to write a script in vbs which will search a website for a phrase, then select or mouse click the phrase, then send TAB to move down to a hyperlink and download a file.
The reason I want to do this, is I have a web archive with constantly updating documents, I want to automatically download the latest document, and the newest hyperlink is always directly below the title phrase "AM FMI Weekly Report". If the script can select the title phrase, and then TAB down, then click the hyperlink, it will ensure I always download the latest document, without ever knowing the filename. Make sense?
Here is the code I have so far, I can search for the Title "AM FMI Weekly Report", but then how do I select or highlight this title, and tab down?:
set ie = Createobject("internetexplorer.application")
Set WshShell = WScript.CreateObject("WScript.Shell")
ie.visible = TRUE
ie.navigate2("
section_id=50882&prod_id=17690")
Do Until IE.Busy = FALSE
WScript.Sleep 10
Loop
If WshShell.AppActivate("SSO login for SupportCentral - Microsoft Internet Explorer") =
TRUE Then
Set theForm = IE.document.Forms(1)
ie.document.login.USER.value="username"
ie.document.login.PASSWORD.value="password"
ie.document.login.submit()
End If
WScript.Sleep 5000
If WshShell.AppActivate("Security Alert") = TRUE Then
WshShell.AppActivate("Security Alert")
WScript.Sleep 10
WshShell.SendKeys "Y"
End If
Do Until IE.Busy = FALSE
WScript.Sleep 10
Loop
Set oHTML = ie.Document
For Each oElement In oHTML.getElementsByTagName("*")
If oElement.innerText = "AM FMI Weekly Report" THEN
oElement.select???
WshShell.SendKeys "{TAB}"
oElement.click
Exit For
End If
Next