This script uses OLE to get a HTML file from the web and then save that file on the local file system.
The following function is part of the executable, and can be found in the System macros Panel.
function DownLoader ( OnlineURL, OfflineFileName , optional absFileName = 0 )' DOWNLOAD a online file, at the URL, to your DeskTop' e.g. message = DOWNLOADER ( "https://ripetech.com/wp-content/uploads/2018/02/WriterDemo.txt" , "WriterDemo.txt" )Dim objHTTP = CreateObject("Microsoft.XMLHTTP")' or' Dim objHTTP = CreateObject("MSXML2.XMLHTTP")' both work on my system!If ( ! objHTTP ) THENMessage ="Could not create object"exit functionEnd IFDim resres = objHTTP.Open ( "GET", OnlineURL , False)objHTTP.senddim waitLoop = 50DOres = objHTTP.statusif res == 200 THEN ' HTML code for finishedwaitLoop = 0ELSEwaitLoop = waitLoop - 1End IFLoop while waitLoopdim rt = objHTTP.responseBodyDim oADOStream = CreateObject("ADODB.Stream")If ( ! oADOStream ) THENMessage ="Could not create object"Set objHTTP = Nothingexit functionEnd IFoADOStream.Type = 1oADOStream.Mode = 3oADOStream.OpenoADOStream.Write (rt)dim SaveAsFIle = IIF ( absFileName , OfflineFileName , getFOlderPath(0) & "\\" & OfflineFileName )if isFile (SaveAsFIle) ThenDeleteFile (SaveAsFIle)End IFoADOStream.SaveToFile ( SaveAsFIle)oADOStream.CloseSet oADOStream = NothingSet objHTTP = NothingDownLoader = SaveAsFIleEND FUNCTION
It can be used to download a file, from a Web site, to a file on the local file system.
e.g. dim myGuitar = downloader ("https://ripetech.com/wp-content/uploads/2017/10/DSC08618-1200x1793.jpg", "Guitar.jpg")
It is called by one of the SOB demos, available via the menu help:
