Hello !

In an application I declare:

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
use the function:

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
and:

Code:
URLDownloadToFile 0, "https://some_url.com", "TextFile.txt", 0, 0
.....
.....
to download a, not so large, web page into a text file.

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