Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Making an IE Window the focus for Excel VBA
I want to extract data from a web page which is called with a Post method
which makes it impossible for me to indicate the URL, so I call the previous page, where there is a link for the page I want and Sendkey Tab to the link and Sendkey Enter. This brings up the page I want in a new window. The problem is that page takes a while to load, and if I use: Do While IE.readystate < 4 DoEvents Loop Do While IE.busy = True DoEvents Loop it does not work, apparently because Excel is still looking at the parent window. I tried using: Dim IES As SHDocVw.ShellWindows Dim IE As SHDocVw.InternetExplorer For Each IE In IES If IE.LocationURL = "http://server.myURL.com:8080/requests.do" Then Do While IE.readystate < 4 DoEvents Loop Do While IE.busy = True DoEvents Loop IE.Visible = True Set IE = IE Exit For End If Next VBA seems to find the right window but when it finds it the window is still loading data and the routine falls through to the next section which reads the data and it errors out because table 300 is not there yet. For now I'm using a sub pause work around to delay several seconds before trying to find and read the new page, but I would like to get Excel to point to the correct window so that the normal Do While code waits just long enough, due to the variability in loading the page and because I am looping through several hundred pages. Any help greatly appreciat ed |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Making an IE Window the focus for Excel VBA
try combining the two do loops. You can't tell which is finishing 1st
Do While IE.readystate < 4 and _ IE.busy = True DoEvents Loop "expect_ed" wrote: I want to extract data from a web page which is called with a Post method which makes it impossible for me to indicate the URL, so I call the previous page, where there is a link for the page I want and Sendkey Tab to the link and Sendkey Enter. This brings up the page I want in a new window. The problem is that page takes a while to load, and if I use: Do While IE.readystate < 4 DoEvents Loop Do While IE.busy = True DoEvents Loop it does not work, apparently because Excel is still looking at the parent window. I tried using: Dim IES As SHDocVw.ShellWindows Dim IE As SHDocVw.InternetExplorer For Each IE In IES If IE.LocationURL = "http://server.myURL.com:8080/requests.do" Then Do While IE.readystate < 4 DoEvents Loop Do While IE.busy = True DoEvents Loop IE.Visible = True Set IE = IE Exit For End If Next VBA seems to find the right window but when it finds it the window is still loading data and the routine falls through to the next section which reads the data and it errors out because table 300 is not there yet. For now I'm using a sub pause work around to delay several seconds before trying to find and read the new page, but I would like to get Excel to point to the correct window so that the normal Do While code waits just long enough, due to the variability in loading the page and because I am looping through several hundred pages. Any help greatly appreciat ed |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Making an IE Window the focus for Excel VBA
Do that happen sequentially?
In any case I think it falls through both of them becuase the focus is on the parent window while the child is still busy opening. ed "Joel" wrote: try combining the two do loops. You can't tell which is finishing 1st Do While IE.readystate < 4 and _ IE.busy = True DoEvents Loop "expect_ed" wrote: I want to extract data from a web page which is called with a Post method which makes it impossible for me to indicate the URL, so I call the previous page, where there is a link for the page I want and Sendkey Tab to the link and Sendkey Enter. This brings up the page I want in a new window. The problem is that page takes a while to load, and if I use: Do While IE.readystate < 4 DoEvents Loop Do While IE.busy = True DoEvents Loop it does not work, apparently because Excel is still looking at the parent window. I tried using: Dim IES As SHDocVw.ShellWindows Dim IE As SHDocVw.InternetExplorer For Each IE In IES If IE.LocationURL = "http://server.myURL.com:8080/requests.do" Then Do While IE.readystate < 4 DoEvents Loop Do While IE.busy = True DoEvents Loop IE.Visible = True Set IE = IE Exit For End If Next VBA seems to find the right window but when it finds it the window is still loading data and the routine falls through to the next section which reads the data and it errors out because table 300 is not there yet. For now I'm using a sub pause work around to delay several seconds before trying to find and read the new page, but I would like to get Excel to point to the correct window so that the normal Do While code waits just long enough, due to the variability in loading the page and because I am looping through several hundred pages. Any help greatly appreciat ed |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I set a pop up window to focus? | Excel Discussion (Misc queries) | |||
How to catch the event when an Excel window gets focus? | Excel Programming | |||
Find/Replace in VBE takes focus off window Excel 2003 | Excel Programming | |||
keep focus & window steady | Excel Programming | |||
Making the minimized Excel window icon flash | Excel Programming |