+ Reply to Thread
Results 1 to 27 of 27

Wait Until Internal Refresh by Website is Complete

  1. #1
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Wait Until Internal Refresh by Website is Complete

    Hello all

    I am currently clicking on a button to perform a search on a website.

    I want to know how I can tell using VBA when this search has finished.

    I am currently using the below code BUT it is does work in the above scenario.

    Please Login or Register  to view this content.
    I have tried doing a search for a hyperlink which I know will appear after the search has finished BUT I got a "runtime error 70 permission denied" in my code.

    When the search is being performed an image comes up and then disappears when the search has been completed. Would it be possible to check when it has disappeared as this would tell me that the search has completed?

    Any thoughts would be greatly appreciated.

    Regards

    Jim

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Wait Until Internal Refresh by Website is Complete

    Hi Jim,

    I'm not good enough to know the nuances of Internet Explorer automation. Occassionally (especially with web sites that use Java script) I can get by with the following code (when I know what the URL is supposed to be:
    Please Login or Register  to view this content.
    The above code is usually preceded by a time delay, or inside a loop.

    I hope this helps.

    Lewis

  3. #3
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Wait Until Internal Refresh by Website is Complete

    Thanks Lewis - I have just tested it but the problem is the expected url changes BEFORE the page has finished searching so defeats the object.

    Anyone else got any ideas?

    Jim

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Wait Until Internal Refresh by Website is Complete


    Hi,

    instead of the first line code with ie.Busy try this one : Do: Loop Until ie.ReadyState = 4

  5. #5
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Wait Until Internal Refresh by Website is Complete

    Quote Originally Posted by Marc L View Post

    Hi,

    instead of the first line code with ie.Busy try this one : Do: Loop Until ie.ReadyState = 4
    I tested it but it closes IE!

    Any other ideas?

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Wait Until Internal Refresh by Website is Complete

    When all else fails, I use a 'wait' command longer than the longest time the website takes to complete. I hate doing this, because:
    a. It makes me feel inadequate.
    b. It takes a long time.
    c. It doesn't always work.

    Lewis

  7. #7
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Wait Until Internal Refresh by Website is Complete

    There must be a way of checking if the page's status is not doing an internal refresh?

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Wait Until Internal Refresh by Website is Complete


    Sure ! It depends on the Web page structure, you have to inspect it …

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wait Until Internal Refresh by Website is Complete

    Hello Jimbo77,

    The problem stems from Internet Explorer running asynchronously. This means VBA and Internet explorer not interlocked when it comes to code execution.

    Normally in VBA, when a Sub or Function calls another Sub or Function its address is placed on the return stack. This enables the other thread to execute and when finished, VBA picks up at the next command in the procedure.

    There are ways to check if Internet Explorer has finished processing but they are slow. There is another way that might work for you. You can directly access the underlying code of Internet Explorer by using the XML HTTP Request object. This will run synchronously with your VBA code.

    If you can describe in more detail what you are doing, I can tell you if this option would work.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  10. #10
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Wait Until Internal Refresh by Website is Complete

    Quote Originally Posted by Leith Ross View Post
    Hello Jimbo77,

    The problem stems from Internet Explorer running asynchronously. This means VBA and Internet explorer not interlocked when it comes to code execution.

    Normally in VBA, when a Sub or Function calls another Sub or Function its address is placed on the return stack. This enables the other thread to execute and when finished, VBA picks up at the next command in the procedure.

    There are ways to check if Internet Explorer has finished processing but they are slow. There is another way that might work for you. You can directly access the underlying code of Internet Explorer by using the XML HTTP Request object. This will run synchronously with your VBA code.

    If you can describe in more detail what you are doing, I can tell you if this option would work.
    That sounds fantastic. What information do you want me to supply in order for you to establish whether XML HTTP Request object will work?

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wait Until Internal Refresh by Website is Complete

    Hello Jimbo77,

    Does accessing the site require a user name and password?

    What information do want to retrieve from the website?

  12. #12
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Wait Until Internal Refresh by Website is Complete

    Yes it does so I obviously can't give these out.

    I want to be able to extract data and also input data on to forms.

    If it is simpler - is there some code that will detect once the webpage has finished its internal refresh? I could perhaps post some html from the page for that?

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wait Until Internal Refresh by Website is Complete

    Hello Jimbo77,

    Since this is a secure site, you will be better off using Internet Explorer.

    Are you just wanting to wait until you are connected to the site after you have logged in?

  14. #14
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Wait Until Internal Refresh by Website is Complete

    After I click a 'filter' button on the website, it performs a search for the information with a graphic of a yellow rotating circle and the caption "Please wait search in progress". I think from looking at the html code it does search for 5 seconds and then refreshes the page and then repeats this process until the requested data is retrieved and then it is displayed.

    I want to know how to delay my code until this internal search is completed and the data has been displayed.

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wait Until Internal Refresh by Website is Complete

    Hello Jimbo77,


    Here are two methods I use with Internet Explorer...
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Wait Until Internal Refresh by Website is Complete

    Leith

    I tried the below code but when the search is completed the code gets stuck in an infinite loop and does not move on...

    Please Login or Register  to view this content.

  17. #17
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wait Until Internal Refresh by Website is Complete

    Hello Jimbo77,

    It probably has changed the the Window caption to the redirected page title. Try using the first wait loop for this and see if it works.

  18. #18
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Wait Until Internal Refresh by Website is Complete

    Tried this but still got stuck in the second loop...

    Please Login or Register  to view this content.

  19. #19
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wait Until Internal Refresh by Website is Complete

    Hello Jimbo77,

    Use only this loop...
    Please Login or Register  to view this content.
    Remove the code for the second loop, since that is where it is hanging up.
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Wait Until Internal Refresh by Website is Complete

    Tried this but now does not wait until search has completed...

    Please Login or Register  to view this content.

  21. #21
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Wait Until Internal Refresh by Website is Complete

    Hello Jimbo77,

    Sorry, I am out of ideas. This is why I don't like answering questions relating to secure sites - too many unknowns. You can't tell me what I need to know and I can't see what is happening on your end.

  22. #22
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Wait Until Internal Refresh by Website is Complete

    The following works for me using Vista (32 bit or Vista 64 bit), Excel 2003, and IE 8:

    Lewis

    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    03-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Wait Until Internal Refresh by Website is Complete

    Thanks Lewis - what is the purpose of the code?

  24. #24
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Wait Until Internal Refresh by Website is Complete

    The code opens the web site using Internet Explorer.

    The 'DiagnosticDebugDotPrint()' routine displays information about the web site, some of which may be useful in your quest to find out if the web site is done doing whatever web sites do.

    I hope this helps.

    Lewis

  25. #25
    Registered User
    Join Date
    04-25-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Wait Until Internal Refresh by Website is Complete

    Hi Jimbo77,

    Did you got any solution for the above problem.

    I'm stuck with the same problem and have tried almost everything that is available on internet.

    Pratik

  26. #26
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Wait Until Internal Refresh by Website is Complete

    pratik.daphal welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  27. #27
    Registered User
    Join Date
    04-25-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Wait Until Internal Refresh by Website is Complete

    Quote Originally Posted by FDibbins View Post
    pratik.daphal welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Thanks Ford!
    I was not aware of the Forum Rules..:P

    I will start a new thread and would also provide a link of this thread, because I find this is similar to what my problem is..

    Regards,
    Pratik Daphal

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Make macro wait for process to complete
    By pjaj in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-13-2012, 01:05 AM
  2. Enable Auto Refresh - Wait for refresh to sinish before running a macro
    By tomlancaster in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2011, 11:52 AM
  3. Make macro wait for process to complete
    By shawnh in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 02-16-2010, 07:52 PM
  4. [SOLVED] Can I use the Excel product icon image on my internal website?
    By newbie in forum Excel General
    Replies: 0
    Last Post: 04-24-2006, 08:35 AM
  5. Wait for Pivot Refresh to Complete
    By Dan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-14-2005, 02:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1