downloading completed?

richarddawson

Board Regular
Joined
Oct 18, 2014
Messages
95
My programme causes a specific site to download a csv workbook. (It does this by sending keystrokes, and strings).

It works perfectly well, but I then want to analyse the sheets. Now I cannot do this until I know the download has completed; but it will not complete while excel is running.

So I need to quit excel; and restart on completion of the download; or, second best, after, say, 30 seconds.

I have looked at event handlers but there is a lot of work involved which I do not want to undertake unless there is a possible solution.

So, please, is it possible?

Cheers Richard
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
The code below given will download the file "winzip21_downwz.exe" from WinZip.com into the folder C:\MyDownloads and when the download is completed, the user will be prompted. Make sure that you have this folder and if not, create it.

Copy and paste the code into a module and run the macro CheckDownload

Code:
Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
'
Sub CheckDownload()
    strURL = "http://download.winzip.com/gl/nkln/winzip21_downwz.exe"
    MyFile = "C:\MyDownloads\winzip21_downwz.exe"
    
    Msg = URLDownloadToFile(0, strURL, MyFile, 0, 0)
    
    DoEvents
    
    Do While Msg <> 0
    
    Loop
    
    MsgBox "Downloading " & MyFile & "to C:\MyDownloads is completed"
End Sub
 
Upvote 0
Hi Haluk,

Thanks for that - an effective answer.

However it does not solve my problem; which is that source site actually initialises the download - but only after I have clicked its download button.

Now I think the very first thing it does is check MY excel to see if it is open. Therefore if I click from Excel I cannot exit excel quickly enough to pass the source's initial test.

So I have to arrange another programme to do the click - and call this from excel. I expect to use Python (hopefully in the excelPython package) to do this. After I have invoked that Python can delay sending the click until Excel has disengaged itself (it does not have to close, just not be running on anything).

My problem is how to find out when to start the excel routines on the downloaded source. I cannot run any timer-dependent sub in excel as that fails the source's check.

I am running update programmes, so they run frequently, downloading many hundreds, if not thousands, of large tables, each update, so the manual alternative is not attractive.

Cheers Richard
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top