Mike Schaper
asked on
Excel Visual Basic error "Object has disconnected from its clients
My macro uses Internet Explorer to open PeopleSoft Financials and then run a public query. It has been working for a long time until recently. I'm aware of an update to Internet Explorer on our machines in early July and am wondering if that has caused this issue.
The macro is throwing an "Object has disconnected from its clients" error message.
Here is how the variable for Internet Explorer is defined: Public ExpApp As InternetExplorer
Here is the code where the error is thown:
Set ExpApp = CreateObject("InternetExpl orer.Appli cation")
ExpApp.Visible = True
ExpApp.navigate vLogin
Do Until ExpApp.readyState = READYSTATE_COMPLETE ' ERROR IS THROWN HERE
MyTimer
Loop
Do Until ExpApp.document.Title <> "PeopleSoft 8 Sign-in"
MyTimer
Loop
Do Until ExpApp.readyState = READYSTATE_COMPLETE
MyTimer
Loop
vLogin is a string with the URL to the PeopleSoft login screen MyTimer is a little function that waits 1 second each time it is kicked off
This macro has been around a while so I imagine that this is pretty old code. I'm hoping there are a few minor changes I could make instead of re-writing this macro. I've attached the code for the macro.
Any suggestions would be greatly appreciated. Thanks for the help......
Code.docx
The macro is throwing an "Object has disconnected from its clients" error message.
Here is how the variable for Internet Explorer is defined: Public ExpApp As InternetExplorer
Here is the code where the error is thown:
Set ExpApp = CreateObject("InternetExpl
ExpApp.Visible = True
ExpApp.navigate vLogin
Do Until ExpApp.readyState = READYSTATE_COMPLETE ' ERROR IS THROWN HERE
MyTimer
Loop
Do Until ExpApp.document.Title <> "PeopleSoft 8 Sign-in"
MyTimer
Loop
Do Until ExpApp.readyState = READYSTATE_COMPLETE
MyTimer
Loop
vLogin is a string with the URL to the PeopleSoft login screen MyTimer is a little function that waits 1 second each time it is kicked off
This macro has been around a while so I imagine that this is pretty old code. I'm hoping there are a few minor changes I could make instead of re-writing this macro. I've attached the code for the macro.
Any suggestions would be greatly appreciated. Thanks for the help......
Code.docx
ASKER
Thanks for the suggestions. I had to use the functions above to get past the issue I was having. The macro is doing a couple of strange things. (1) It is displaying the messages "IE has closed" Opening Web Page has timed out" but keeps on running. ( I haven't stepped though it yet). It is almost like it is opening the PeopleSoft signon page twice but I only see one. Once it opens the user has to key in their user id and password. the first time I key it, it goes blank and says user id or password is invalid. Then the second time the logon works.
The macro is able to navigate to the query screen and fill in the prompts. However when it hits the command below, nothing happens.
ExpApp.navigate vSubmit
vSubmit is a variable that contains "javascript:submitAction_w in0(docume nt.win0,'# ICQryDownl oadExcelFr mPrompt'); ".
So it is kind of good news / bad news but it is progress. Thanks again for your help..........
The macro is able to navigate to the query screen and fill in the prompts. However when it hits the command below, nothing happens.
ExpApp.navigate vSubmit
vSubmit is a variable that contains "javascript:submitAction_w
So it is kind of good news / bad news but it is progress. Thanks again for your help..........
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are correct. After it fills in the 4 prompts, the next step is to push the button; which runs the query and displays the results
I would suggest the following:
1. Add "Microsoft Internet Controls" to your "Tools/References" list in VBA
2. Create your ExpApp variable as follows, rather than using "CreateObject"
Open in new window
3. If the error persists, try defining ExpApp asOpen in new window
and creating it accordingly.
The "medium" version of the object interacts differently with security settings.
4. If you still have a problem, the following code may help. It requires a further addition to "tools/references" namely the DLL called "Microsoft Shell Controls and Automation"
This routine runs through all open windows (visible and invisble) in search of the one that references the URL you are trying to access, and reconnects to it
Open in new window
I use a version of the routine above with the five short routines below to access urls, and it seems to work reliably (for now.. there may be further issues with Excel2016). You need to define ExpApp at the module level for this to work.
Open in new window
Hope this helps.