I'm working on a longer script for Access and at one point it is necessary to check a webservice for the latest version of a file (the filename). This webservice is only accessible via a browser where it is necessary to athenticate. I already managed to open an Internet Explorer window (which is visible although it shouldn't). However after that I get the error
Method 'Busy' of object 'IWebBrowser2' failed
Right now I have the following code:
Dim appIE As Object
Dim sURL as String, infoStr as String
Set appIE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}") 'class id of InternetExplorerMedium
sURL = "https://webservice.example.com:1234/Server/test.jsp?parameter=value"
With appIE
.Navigate sURL, Headers:=CreateBasicAuthHeader("MyUsername", "MyPassword")
.Visible = False
End With
Do While appIE.Busy Or appIE.ReadyState <> 4
DoEvents
Loop
infoStr = appIE.Document.getElementsByTagName("body").item.innerText
which works well until the line:
Do While appIE.Busy Or appIE.ReadyState <> 4
If I'd leave the loop out the same error would appear but for 'Document' instead of 'Busy' in line infoStr = appIE.Document.getElementsByTagName("body").item.innerText
. Considering that also .Visible = False
has no impact (I can see the browser window) I think that any operation on appIE
after .Navigate
isn't working. But I have no idea why.
After searching a while after the mentioned error I found 3 possible solutions but neither of them succeed.
- Using the
.Busy
or.ReadyState
properties to prevent the macro from proceeding while the browser hasn't completely loaded the site. Which I obviously already do. - Using internet explorer at a medium integrity level. Which I also already do.
- Searching the Task Manager for any "orphaned" IE processes. There are none.
Any help or idea is greatly appreciated.