Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Web page loading

Does anyone have a non-time based vba code that allows vba
to detect when a web page has loaded after focus has been
thrown to Internet Explorer from Excel using Appactivate?

Currently I am inserting data from a text file into
specific fields on a web page and then pressing a button
on the page to receive the results. The results are then
saved using IE's "save as" function. However, since the
internet is not instantaneous, I need to have a way to
detect that the web page has been loaded. Using a timer
doesn't work since the amount of time is random and
assigning an estimated time means that the wait time has
to be adjusted every time this program runs.

Any advice about how to detect whether the page has loaded?

Thanks,

Matt


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Web page loading

Hi Matt,

You can do this if you are Automating Internet Explorer, but I don't know if
you can using AppActivate.

Here are the basics of doing it via Automation:

Sub test23()
Dim ie As InternetExplorer

Set ie = New InternetExplorer

ie.Navigate URL:="http://www.longhead.com/"

Do While ie.Busy Or Not ie.ReadyState = _
READYSTATE_COMPLETE
DoEvents
Loop

MsgBox ie.Document.body.innertext

ie.Quit
Set ie = Nothing
End Sub

You must set a reference to Microsoft Internet Controls in order to use
this. Or you can use Late Binding if you don't want to set a reference.

You can also sink the Internet Explorer events so you don't have to make the
user wait for the document to load - you can just call another subroutine or
take a specific action once the DocumentComplete event fires. This is a bit
tricky, but if you'd like to see some sample code, I'd be happy to post it
for you.

--
Regards,

Jake Marx
www.longhead.com


Matt Cohen wrote:
Does anyone have a non-time based vba code that allows vba
to detect when a web page has loaded after focus has been
thrown to Internet Explorer from Excel using Appactivate?

Currently I am inserting data from a text file into
specific fields on a web page and then pressing a button
on the page to receive the results. The results are then
saved using IE's "save as" function. However, since the
internet is not instantaneous, I need to have a way to
detect that the web page has been loaded. Using a timer
doesn't work since the amount of time is random and
assigning an estimated time means that the wait time has
to be adjusted every time this program runs.

Any advice about how to detect whether the page has loaded?

Thanks,

Matt


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Web page loading


Jake:

Thank you for your response. I am not familiar with the
references you mentioned, Microsoft Internet Controls and
Late Binding. Are these Options declared prior to the
sub? Your code would provide what I need once I
understand these.

I appreciate any help you could provide.

Thanks,

Matt

-----Original Message-----
Hi Matt,

You can do this if you are Automating Internet Explorer,

but I don't know if
you can using AppActivate.

Here are the basics of doing it via Automation:

Sub test23()
Dim ie As InternetExplorer

Set ie = New InternetExplorer

ie.Navigate URL:="http://www.longhead.com/"

Do While ie.Busy Or Not ie.ReadyState = _
READYSTATE_COMPLETE
DoEvents
Loop

MsgBox ie.Document.body.innertext

ie.Quit
Set ie = Nothing
End Sub

You must set a reference to Microsoft Internet Controls

in order to use
this. Or you can use Late Binding if you don't want to

set a reference.

You can also sink the Internet Explorer events so you

don't have to make the
user wait for the document to load - you can just call

another subroutine or
take a specific action once the DocumentComplete event

fires. This is a bit
tricky, but if you'd like to see some sample code, I'd be

happy to post it
for you.

--
Regards,

Jake Marx
www.longhead.com


Matt Cohen wrote:
Does anyone have a non-time based vba code that allows

vba
to detect when a web page has loaded after focus has

been
thrown to Internet Explorer from Excel using

Appactivate?

Currently I am inserting data from a text file into
specific fields on a web page and then pressing a button
on the page to receive the results. The results are

then
saved using IE's "save as" function. However, since the
internet is not instantaneous, I need to have a way to
detect that the web page has been loaded. Using a timer
doesn't work since the amount of time is random and
assigning an estimated time means that the wait time has
to be adjusted every time this program runs.

Any advice about how to detect whether the page has

loaded?

Thanks,

Matt


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Web page loading

Hi Matt,

If you go to the VBE and select Tools | References, look for Microsoft
Internet Controls and check the box next to it. That will allow Excel to
use the necessary library for the code to work as written.

Late Binding refers to using the library without referencing it in your VBA
project. To do this, you would have to declare ie As Object, use
CreateObject to create an instance of the IE application, and replace the
READYSTATE_COMPLETE constant with its actual value (4). If you do all these
things, you don't need to set a reference to the library to get your code to
work. Late Binding is a lot slower if you're making a lot of calls to the
library, but in this case, you probably won't notice a difference. Late
Binding is nice in that you don't have to worry about whether the user will
have a different version of a library on his/her machine. And you can trap
the runtime error generated by CreateObject if the library doesn't exist on
the user's machine. With Early Binding (setting a reference and declaring
As InternetExplorer), you cannot trap the error the user will get if he/she
doesn't have the necessary library on the machine.

--
Regards,

Jake Marx
www.longhead.com

Matt Cohen wrote:
Jake:

Thank you for your response. I am not familiar with the
references you mentioned, Microsoft Internet Controls and
Late Binding. Are these Options declared prior to the
sub? Your code would provide what I need once I
understand these.

I appreciate any help you could provide.

Thanks,

Matt

-----Original Message-----
Hi Matt,

You can do this if you are Automating Internet Explorer, but I don't
know if you can using AppActivate.

Here are the basics of doing it via Automation:

Sub test23()
Dim ie As InternetExplorer

Set ie = New InternetExplorer

ie.Navigate URL:="http://www.longhead.com/"

Do While ie.Busy Or Not ie.ReadyState = _
READYSTATE_COMPLETE
DoEvents
Loop

MsgBox ie.Document.body.innertext

ie.Quit
Set ie = Nothing
End Sub

You must set a reference to Microsoft Internet Controls in order to
use this. Or you can use Late Binding if you don't want to set a
reference.

You can also sink the Internet Explorer events so you don't have to
make the user wait for the document to load - you can just call
another subroutine or take a specific action once the
DocumentComplete event fires. This is a bit tricky, but if you'd
like to see some sample code, I'd be happy to post it for you.

--
Regards,

Jake Marx
www.longhead.com


Matt Cohen wrote:
Does anyone have a non-time based vba code that allows vba
to detect when a web page has loaded after focus has been
thrown to Internet Explorer from Excel using Appactivate?

Currently I am inserting data from a text file into
specific fields on a web page and then pressing a button
on the page to receive the results. The results are then
saved using IE's "save as" function. However, since the
internet is not instantaneous, I need to have a way to
detect that the web page has been loaded. Using a timer
doesn't work since the amount of time is random and
assigning an estimated time means that the wait time has
to be adjusted every time this program runs.

Any advice about how to detect whether the page has loaded?

Thanks,

Matt


.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Web page loading

Jake:

Thanks again for your help.

Matt
-----Original Message-----
Hi Matt,

If you go to the VBE and select Tools | References, look

for Microsoft
Internet Controls and check the box next to it. That

will allow Excel to
use the necessary library for the code to work as written.

Late Binding refers to using the library without

referencing it in your VBA
project. To do this, you would have to declare ie As

Object, use
CreateObject to create an instance of the IE application,

and replace the
READYSTATE_COMPLETE constant with its actual value (4).

If you do all these
things, you don't need to set a reference to the library

to get your code to
work. Late Binding is a lot slower if you're making a

lot of calls to the
library, but in this case, you probably won't notice a

difference. Late
Binding is nice in that you don't have to worry about

whether the user will
have a different version of a library on his/her

machine. And you can trap
the runtime error generated by CreateObject if the

library doesn't exist on
the user's machine. With Early Binding (setting a

reference and declaring
As InternetExplorer), you cannot trap the error the user

will get if he/she
doesn't have the necessary library on the machine.

--
Regards,

Jake Marx
www.longhead.com


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
loading add ins [email protected] Excel Discussion (Misc queries) 0 October 30th 08 02:51 PM
Loading... K Excel Discussion (Misc queries) 1 October 7th 07 09:37 PM
loading mallahd Excel Discussion (Misc queries) 2 May 25th 07 07:59 PM
Loading a Different Page Robert Maddox Excel Discussion (Misc queries) 0 October 20th 06 07:16 PM
Add-ins not loading John F Excel Discussion (Misc queries) 2 February 17th 05 08:54 PM


All times are GMT +1. The time now is 04:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"