View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Walter Briscoe Walter Briscoe is offline
external usenet poster
 
Posts: 279
Default Need help with macro

In message of Thu,
7 May 2009 03:10:01 in microsoft.public.excel.programming, joel
writes

Joel,
Thanks for a quick response. The problem I have on one system is with IE
rather than a particular URL. CreateObject + IE.Visible = TRUE opens one
window. IE.Navigate2 URL opens a second window. i.e. the second window
has no obvious connection with the first. I take it the problem is with
my Internet Explorer configuration rather than anything else. I compared
tools\internet options - particularly focussing on the advanced tab -
eliminated all differences and nothing changed. My problem is not with
the site. It is that the URL is opened in a child of the object rather
than in the object. I am inclined to install IE8 and see if the problem
goes away.


Walter: I experience the same problem yesterda with READYSTATE_UNINITIALIZED
(3). I wrote th e macro on my PC and home which has a version of excel
2002/2003 and it worked. I tried the code at work which has a newer verion
of excel which is 2003 but doesn't have all the updates from microsoft and
got the READYSTATE_UNINITIALIZED problem. I assumed the problem was due to
some updates that was missing.

This website is weird. The table numbers and data vary each time you run
the code. I needed to get the table starting with the string "Trading
Methodology:". Normally when I run code like this the table number is fixed.
this time I found sometimes the "Trading Methodology:" table was table
number 10 and sometimes it was 11. So I added code to the macro to actually
search for the string in all the tables. I used INSTR to find the string and
found it appear in the middle of one of the tables and was at the beginning
of anothe table. I then switched from using INSTR() to LEFT() = "Trading
Methodology:".

I don't have permission at work to download upgrades from microsoft.con. If
you can try getting all the upgrades and service packs and see if the problem
disappears.

I had to go to microsoft.com and search for READYSTATE_UNINITIALIZED to find
out the value was 3. I still can't get the code to run on my pc at work. I
have to comment out the test for IE.readyState and step through the code to
get it too work. You could add a time and wait for 5 seconds instead of the
test.

"Walter Briscoe" wrote:

In message of Tue,
5 May 2009 16:17:01 in microsoft.public.excel.programming, joel
writes
I couldn't get the query top work. Instead of using an internet explorer to
get the data. It puts the results on sheet 1 using Column A and Column B
from sheet 2.


Sub WebQuery()


[snip]

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True


[snip]

IE.Navigate2 URL


Joel's demonstration code is REALLY interesting to me.

I run Excel 2003 with IE7 on Windows XP SP2.
A second machine has a similar system, but with Windows XP SP3.

I think I have a configuration issue in IE.

At "IE.Visible = True", an instance of IE is shown with Favorites open;
on the 2nd machine Favorites is not opened.

"IE.Navigate2 URL" results in a 2nd instance of IE being opened -
probably a child of the 1st - and IE.readyState retains a value of
READYSTATE_UNINITIALIZED. On the 2nd machine, the URL is opened in the
1st instance and IE.readyState soon goes to READYSTATE_COMPLETE which I
infer is 4.

What should I do to correct this problem?
Where should I read about the methods (and properties) of the
"InternetExplorer.Application" object?

Thanks!
--
Walter Briscoe


--
Walter Briscoe