Solved

Error 80020101 while calling javascript function from Visual Basic

Posted on 2007-03-25
2
11,256 Views
Last Modified: 2013-11-27
Hi Gurus,
I am facing problem while calling a javascript function from Visual basic. Basically my requirement is like this.

First I have to invoke a web page from visual basic and once it is called, I have to invoke javascript function in it. While debugging the code, I could see that the web page gets loaded successfully but the code gives error 80020101 when it executes the call to javascript function. Below is the code that I have used.

Dim oIE As Object
'Create the IE application object.
oIE = CreateObject("internetexplorer.application")
'Load the URL.
oIE.Navigate("http://xyz.net:8065/bc/bsp/crm_ic/default.htm?sap-client=220&sap-sessioncmd=open")
'Wait for the web page to load completely.
Do While (oIE.ReadyState <> 4)
Loop
'MsgBox(oIE.Document.frames.length)
Call oIE.Document.parentWindow.execScript("window.top.setProduct('1105206503')", "JavaScript")

I could successfully simulate the process by doing following steps -
1. Paste the URL in web brower and let the page load successfully.
2. Now paste the function in web browser like javascript:window.top.setProduct('1105206503')
By doing this, it calls the function successfully.

But when I am trying to execute this through VB code I get error 80020101.
I tried statements like -
Call oIE.Document.frames.execScript("window.top.setProduct('1105206503')", "JavaScript")
or
Call oIE.Document.frames(0).execScript("window.top.setProduct('1105206503')", "JavaScript")

but no use.

The statement MsgBox(oIE.Document.frames.length) returns 0 suggesting that there is only one frame on the page.

Help please.

Thanks,
Rahul.
0
Comment
Question by:raurangabadkar
2 Comments
 
LVL 7

Accepted Solution

by:
Dimandja earned 250 total points
ID: 18790237
0
 

Author Comment

by:raurangabadkar
ID: 18791381
Hi Master,

Thanks for the link. I checked it and tried few possibilities mentioned in it.

Today I started testing my code a fresh and I realized that may be I was not waiting enough for the page to get loaded successfully.

I added a wait in my code and now it has started working fine.

Points awarded.

Thanks,
Rahul.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with sorting data in Listbox using VB.NET 3 53
Help with Query not working in client's PC 1 35
Help with Syntax 9 28
Windows ICD FFU Issue 4 14
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now