+ Reply to Thread
Results 1 to 6 of 6

VBA code to wait until file download from IE is complete

  1. #1
    Registered User
    Join Date
    10-28-2013
    Location
    bangalore
    MS-Off Ver
    Excel 2013
    Posts
    37

    VBA code to wait until file download from IE is complete

    Hello All,

    I'm trying to download an excel file from a webpage and so far I was able to open the webpage, navigate and click on save button but I need to access that excel file once it is downloaded. But sometimes it takes time to download depending on the size of the file. Is there any way we can check the window and see if the download is complete and only then to proceed to open the downloaded file. Below is the code.

    #Dim o As IUIAutomation
    Dim e As IUIAutomationElement
    Set o = New CUIAutomation
    h = IE.hwnd

    h = FindWindowEx(h, 0, "Frame Notification Bar", vbNullString)

    If h = 0 Then

    MsgBox "Not Found"

    End If


    Set e = o.ElementFromHandle(ByVal h)
    Dim iCnd As IUIAutomationCondition
    Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "Save")

    Dim Button As IUIAutomationElement
    Set Button = e.FindFirst(TreeScope_Subtree, iCnd)
    Dim InvokePattern As IUIAutomationInvokePattern
    Set InvokePattern = Button.GetCurrentPattern(UIA_InvokePatternId)
    InvokePattern.Invoke #

    The above code will save the download file

    Reference:- http://stackoverflow.com/questions/3...ie-is-complete

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA code to wait until file download from IE is complete

    Hello Yash20,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Regards
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA code to wait until file download from IE is complete

    Cross posted...

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA code to wait until file download from IE is complete

    @cytop,

    Cross posted...
    In all fairness, albeit not exactly the correct way, the OP did add a Reference to where he has posted the same Thread.

    @Yash20,

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    The corrected way would be to state: Also Posted here: http://stackoverflow.com/questions/3...ie-is-complete

    Instead of just stating: Reference; http://stackoverflow.com/questions/3...ie-is-complete

    Regards,

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VBA code to wait until file download from IE is complete

    Aware of that. Also on another foru other than SO.

    I will not post links, that's the responsibility of the OP but perhaps I should have made it clearer there were other threads. I blame my phone with its terrible keyboard.
    Last edited by cytop; 10-10-2016 at 04:03 AM.

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA code to wait until file download from IE is complete

    @cytop,

    I will not post links, that's the responsibility of the OP
    Absolutely, neither would I.

    I blame my phone with its terrible keyboard.
    Disagree, I blame you for a bad choice!

    Thank you for your time and contribution though!

    Best Regards.

+ 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. Wait Until Internal Refresh by Website is Complete
    By Jimbo77 in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 11-21-2017, 03:33 AM
  2. Download text file from web without complete filename
    By osubuckeye2007 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-21-2014, 12:48 PM
  3. 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
  4. Wait for the code to execute before complete opening of excel
    By camaytoc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-06-2012, 09:59 AM
  5. Script & VBA Code download an FTP file
    By howard101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-31-2010, 05:34 PM
  6. 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
  7. [SOLVED] 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