Link to home
Start Free TrialLog in
Avatar of stefanteulon
stefanteulon

asked on

Call a javascript function in vb

This is very urgent!!

Is it possible to call a javascript function from vb, currently I've got:

Function BrowseIt()
Dim ieBrowser As Object
Dim oForm

Set ieBrowser = CreateObject("InternetExplorer.Application")

ieBrowser.navigate "http://www.intexmirror.com/intexnet/"
ieBrowser.Visible = True
Set oForm = ieBrowser.Document.Forms("WebTraderfrm")

oForm.all("shemp").Value = "teul****"
oForm.submit

Set oForm = ieBrowser.Document.Forms("WebTraderFrm")

oForm.all("USER_DEAL_NAME").Value = "MIDOC001"

______________________________________________________________________________________________________________
'NOT WORKING BELOW THIS LINE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

ieBrowser.Document.parentWindow.execScript "USER_DEAL_NAME.value = SelectDealGO();", "javascript"

ieBrowser.Visible = False
Set ieBrowser = Nothing

End Function


I constantly get a run-time error number of '-2147352319 (80020101)'  Could not complete the operation due to error 80020101


the source code from the web page is:

"<TD CLASS=D ALIGN=left> <A onMouseOver=ShowPopup(this,'Action','SelectCusip') onMouseOut=HidePopup()><FONT SIZE=1><INPUT TYPE=radio NAME=DEAL_OR_SEARCH VALUE=deal CHECKED> CUSIP, ISIN, CINS, or DEAL ID</FONT></A>  <TD CLASS=D ROWSPAN=2> <FONT SIZE=1>&nbsp; <INPUT TYPE=text NAME=USER_DEAL_NAME VALUE='SOLSTICE' SIZE=30 onFocus=this.select() onKeyPress=SelectDealKeyPress(event)> &nbsp;</FONT>  <TD CLASS=D ROWSPAN=2> <A HREF="Javascript:SelectDealGo()"><FONT SIZE=1> <IMG BORDER=0 SRC=/images/webtrader/GreenGoBtn.gif ALT='Get deal info'> </FONT></A>  
"

Any help would so greatly appreciated!!!

ASKER CERTIFIED SOLUTION
Avatar of EDDYKT
EDDYKT
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stefanteulon
stefanteulon

ASKER

Mate you Legend, that was just the ticket, took a bit of manipulation but in essence is was the right direction to point me in, my code i needed was:

Call ieBrowser.Document.frames.execScript("SelectDealGo()", "JavaScript")

Works a treat.

Just one more questin if you don't mind, do you know what property I can use to tell if the page has finished loading? I.e I run a script, then make the code wait using a validifying loop until the page is flagged to say that it is finished loading, then the code continues with somehting else on the loaded page?

cheers
i don't think you can do in your way

however, if you use ms internet controls (shdocvw.dll), you may be able to trap some event

ie

NavigateComplete2, DocumentComplete etc
This was sort of where i was looking down but i don;t think you code can sit there and think, i.e. wait until documentComplete. The way i was going to solve would be to create a loop that only moves on when DocumentComplete = true.

Is this feasible?
you can create a loop to check the readystate too
just done it mate, cheers for your help, I simple put:

Do Until WebBrowser.Busy = false
loop

works a treat

cheer