|
hey all,
I've been trying to write a VBA program that will allow for automation of Javascript, but am having a lot of trouble with it. Right now I have:
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate ("http://www.bloomberg.com")
IE.Visible = True
Dim i As Integer
Dim j As Integer
Application.Wait (Now + TimeValue("0:00:05"))
Set objForms = IE.document.forms
For i = 0 To objForms.Length - 1
For j = 0 To objForms.Item(i).Length - 1
Cells(j + 1, i + 1) = objForms.Item(i).Item(j).Name
Cells(j + 2, i + 1) = objForms.Item(i).Item(j).Type
Cells(j + 3, i + 1) = objForms.Item(i).Item(j).Value
Next
Next
I'm attempting to automatically enter a stock symbol into the Bloomberg website and pull up the quote page. The code above essentially lists all names/types/values of each items in the window in an Excel spreadsheet... One of the items that comes up is a textbox with the name "myticker", so within the second for-loop I put in:
If (objForms.Item(i).Item(j).Name = "myticker") Then
objForms.Item(i).Item(j).Value = "MSFT"
End If
And this seems to successfully input the microsoft ticker into the box.... The button to submit the symbol and pull up the quote isn't showing up as any of the items in the spreadsheet, though, and when I attempt forms(0).submit and forms(1).submit [there seem to be two forms in the window] neither of them seem to pull up the quote page. In the source code, the button seems to be programmed as:
'<td><input value="quote" onClick="document.pressed=this.value" type="image" 'src="http://images.bloomberg.com/r06/navigation/quote_quote_btn.gif" hspace="6"></td>
If VBA were to detect that there was an item in the form with value "quote" then I figure I could just do:
If (objForms.Item(i).Item(j).Value = "quote") Then
objForms.Item(i).Item(j).onClick
End If
and it would theoretically work, but I don't understand why VBA isn't detecting that this button is on the page. Is it possible to run this javascript through VBA somehow???
Thanks,
Jeff T.
|
|
|
|
|
|
|
// |