ballgnm
New Member
- Joined
- Jan 16, 2023
- Messages
- 12
- Office Version
- 2021
- 2019
- 2016
- 2013
- Platform
- Windows
Hello folks.
I'm doing an excel file that needs to download a chromedriver.
I can't track the percentage of download process from filestream as it waits until it finishes to write.
Is there any way to get size of filestream as it's getting fetched from internet.
Well, chromedriver is only 6.8 MB so it's faster to download. I've tried with bigger files and still the same.
This is what I've tried.
I'm doing an excel file that needs to download a chromedriver.
I can't track the percentage of download process from filestream as it waits until it finishes to write.
Is there any way to get size of filestream as it's getting fetched from internet.
Well, chromedriver is only 6.8 MB so it's faster to download. I've tried with bigger files and still the same.
This is what I've tried.
VBA Code:
Private Sub driverDownload(ByVal dVersion As String)
Dim http As New MSXML2.XMLHTTP60
Dim url As String
Dim fileSize As Double
Dim recieved As Double
Dim fileStream As Object
url = "https://chromedriver.storage.googleapis.com/" + dVersion + "/chromedriver_win32.zip"
Set http = New MSXML2.XMLHTTP60
http.Open "GET", url, False
http.send
recieved = 0
If http.Status = 200 Then
fileSize = mdlChromeDriver.http.getResponseHeader("Content-Length")
Set fileStream = VBA.CreateObject("ADODB.Stream")
fileStream.Open
fileStream.Type = 1
fileStream.Write http.responseBody
Do While recieved < fileSize
recieved = fileStream.Size
Debug.Print "Downloading " & Round(recieved / fileSize * 100, 2) & " %"
DoEvents
Loop
fileStream.SaveToFile Environ("USERPROFILE") & "\Desktop\chromedriver " & dVersion & ".zip", 2
fileStream.Close
End If
Set http = Nothing
End Sub
Last edited: