Hi there,
I've been struggling with a problem for a macro that uses IE to open up a webpage and download values from a table to Excel.
The macro works fine on all but 1 of my colleagues computers here at work. I can't figure out why his computer behaves the way it does, as it should have all the same settings and installations as we have (I work at a larger company).
I've cut out some parts of the code below as I know that it is not part of the problem.
For us other users the code works fine, the only thing we see while the macro is running is the progressbar. We can't see the IE-window open up and so on, since its done in the background.
But for the other user, a internet explorer window pops up at the "ie.navigate url" part, and the macro stops at either "IE.Busy" or "IE.Document" since it doesn't seem to know that IE is running..
We have the same versions of excel and internet explorer, windows etc.. Same references are checked in the VBA.. But somehow his Excel can recognize IE.Navigate but after that it can't control the IE-application..
Anyone had a similar problem or have any suggestions for what I can try?
Thanks.
I've been struggling with a problem for a macro that uses IE to open up a webpage and download values from a table to Excel.
The macro works fine on all but 1 of my colleagues computers here at work. I can't figure out why his computer behaves the way it does, as it should have all the same settings and installations as we have (I work at a larger company).
I've cut out some parts of the code below as I know that it is not part of the problem.
For us other users the code works fine, the only thing we see while the macro is running is the progressbar. We can't see the IE-window open up and so on, since its done in the background.
But for the other user, a internet explorer window pops up at the "ie.navigate url" part, and the macro stops at either "IE.Busy" or "IE.Document" since it doesn't seem to know that IE is running..
We have the same versions of excel and internet explorer, windows etc.. Same references are checked in the VBA.. But somehow his Excel can recognize IE.Navigate but after that it can't control the IE-application..
Anyone had a similar problem or have any suggestions for what I can try?
Thanks.
Code:
Sub Grupp_3()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim IE As Object
Dim tbls, tbl, trs, tr, tds, td, r, c
Dim countery2 As Long
Dim ANTAL As Long
Set IE = CreateObject("internetexplorer.application")
On Error GoTo ErrMsg
ActiveWorkbook.Sheets("IMPORT").Select
Range("A239:I306").ClearContents
Radhopp = Range("O31").Value
Set KODER = Range("Q31:Q34")
countery = 1
ANTAL = 4
UpdateProgressBar 0, ANTAL
For Each Row In KODER.Cells
ActiveWorkbook.Sheets("IMPORT").Select
IE.navigate " real URL here"
' Wait while IE loading...
Do While IE.Busy
Application.Wait DateAdd("s", TID, Now)
Loop
Set tbls = IE.Document.getElementsByTagName("table")
For r = 0 To tbls.Length - 1
Debug.Print r, tbls(r).Rows.Length
Next r
Set tbl = IE.Document.getElementById("TABLE_OVERVIEW")
Set trs = tbl.getElementsByTagName("tr")
For r = 0 To trs.Length - 1
Set tds = trs(r).getElementsByTagName("td")
'if no then look for
If tds.Length = 0 Then Set tds = trs(r).getElementsByTagName("th")
For c = 0 To tds.Length - 1
ActiveSheet.Cells(Radhopp, 1).Offset(r, c).Value = tds(c).innerText
Next c
Next r
' code continues but problem arises earlier.