
There are situations where we need to pause our macro running process to complete other sets of tasks. IntDone = URLDownloadToFile(0, "", "C:\Users\Matt\Desktop\testfiledownload. VBA Sleep function is a windows function present under windows DLL files which is used to stop or pause the macro procedure from running for a specified amount of time after that certain amount of we can resume the program. Private Declare Function URLDownloadToFile Lib "urlmon" _Īlias "URLDownloadToFileA" (ByVal pCaller As Long, _īyVal szURL As String, ByVal szFileName As String, _īyVal dwReserved As Long, ByVal lpfnCB As Long) As Long Excel 2003 running on Windows Vista Ultimate, 4 GB RAMĭeclare Sub sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long) But, the contents of the text file have been concatenated. However, when I try to transfer the file using URLDownloadToFile using Excel, the file is still downloaded from my website without any error. Option Explicit Declare PtrSafe Sub Sleep Lib 'kernel32' (ByVal a As Lo. When I check the formatting of the just-transferred file, it appearsĮxactly as shown above. Using my FTP program, I can then transfer the file directly back to my PC. I upload this file via FTP to my web server without any problems. For example, I have a text file on my PC containing strings of numbers that looks similar to the following: To understand why the original formatting of the text file is changed when using the URLDownloadToFile procedure. However, the contents of that text file become concatenated upon download.



My procedure downloads a text file from my website to my PC. I am using Excel 2003 and the API function URLDownloadToFile.
