I use the following code and it has been working very well in the past, but now I'm geting worried that the filesize is geting larger and larger.
Code snippet:
sub test()
DownloadXlam "http://www.hellis.me/Install_files/Flysight.xlam", "C:\Flysight\Flysight.xlam"
MyFile = "C:\Flysight\MoveFlysight.bat"
Set objExcel = New Excel.Application
strExcelPath = objExcel.Path & "\"
Set objExcel = Nothing
fnum = FreeFile()
Open MyFile For Output As #fnum
If Application.OperatingSystem = "Windows (32-bit) NT 5.01" Then
Print #fnum, "ping -n 3 127.0.0.1>nul"
Else
Print #fnum, "timeout /T 2 >nul"
End If
Print #fnum, "move /Y C:\Flysight\Flysight.xlam " & Chr(34) & Application.UserLibraryPath & "Flysight.xlam" & Chr(34)
Print #fnum, "start " & Chr(34) & " " & Chr(34) & " " & Chr(34) & strExcelPath & "excel.exe" & Chr(34) & " " & Chr(34) & Application.ActiveWorkbook.Path & "\" & wkbName & Chr(34)
Close #fnum
Shell MyFile, vbNormalFocus
On Error Resume Next
Application.Interactive = False
AppActivate "Microsoft Excel"
Application.Quit
end sub
Private Function DownloadXlam(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFileA(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadXlam = True
End Function
The code probably won't run due to many variables are "missing".
The first line downloads the file to a folder and after that it creates a bat-file that later moves the xlam-file (installs it). (the ? & Now is to make sure it does not read from cache memory)
Because the xlam file is currently 1.2 MB I'm worried that if the user has a slow internet the VBA code will finnish creating the bat-file and running the bat-file before the file has been downloaded.
Is this something I should be worried about? Or does the code "wait" for the file?
Anyone who knows? Or if it does not wait what do I need to do to make it wait?