codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  is automating javascript through VBA possible??  jtornick at 20:12 on Sunday, August 10, 2008
 

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.











CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: import contacts of msn/yahoo
•  Palm Inc. Online Recruitment Event
•  Palm Inc. Online Recruitment Event
•  Palm Inc. Online Recruitment Event
•  Palm Inc. Online Recruitment Event
•  Re: What does this do?
•  Re: Folder name with
•  is automating javascript through VBA possible??
•  Re: How do i deactivate my button


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008