downloading completed?

richarddawson

Board Regular
Joined
Oct 18, 2014
Messages
72
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
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Haluk

Rules Violation
Joined
Oct 26, 2002
Messages
1,075
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
 

richarddawson

Board Regular
Joined
Oct 18, 2014
Messages
72
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
 

Forum statistics

Threads
1,089,676
Messages
5,409,675
Members
403,275
Latest member
Thegoldenone

This Week's Hot Topics

Top