Hello !
In an application I declare:
use the function:Code:Public 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
and:Code:Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean Dim lngRetVal As Long lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0) If lngRetVal = 0 Then DownloadFile = True End Function
to download a, not so large, web page into a text file.Code:URLDownloadToFile 0, "https://some_url.com", "TextFile.txt", 0, 0 ..... .....
When I start the application the first time often nothing happens. (Nothing is downloaded !)
But if I first manually, with a web browser, open the same website, close it again and thereafter re-run the application, everything works as it should and then every attempt !
At least that's the case in design mode....
What can I add to the application to make it download the web page at the first start, without having to preopen the website ?
Best regards and thanks in advance.
/Kalle




Reply With Quote