codeperson
08-27-2013, 10:42 PM
I have a VBA code to download files from internet. The code automatically chooses Internet Explorer to open the URLs and to download the pdf files. I would like the code to automatically choose Google Chrome instead of IE to open the URLs to download files. But I don't know how to modify the code. Please help if you know.
For your reference, the code I'm using is:
Function SaveWebFile(ByVal vWebfile As String, ByVal vLocalFile As String) As Boolean
Dim oXMLHTTP As Object, i As Long, vFF As Long, oResp() As Byte
Set oXMLHTTP = CreateObject("msxml2.xmlhttp")
oXMLHTTP.Open "GET", vWebfile, False 'Open socket to get the website
oXMLHTTP.Send 'send request
'Wait for request to finish
Do While oXMLHTTP.readyState <> 4
DoEvents
Loop
'Returns the results as a byte array
oResp = oXMLHTTP.ResponseBody
'Create a local file and save result to it
vFF = FreeFile
If Dir(vLocalFile) <> "" Then Kill vLocalFile
Open vLocalFile For Binary As #vFF
Put #vFF, , oResp
Close #vFF
Set oXMLHTTP = Nothing
End Function
Edited to add Code Tags. (The # button)
For your reference, the code I'm using is:
Function SaveWebFile(ByVal vWebfile As String, ByVal vLocalFile As String) As Boolean
Dim oXMLHTTP As Object, i As Long, vFF As Long, oResp() As Byte
Set oXMLHTTP = CreateObject("msxml2.xmlhttp")
oXMLHTTP.Open "GET", vWebfile, False 'Open socket to get the website
oXMLHTTP.Send 'send request
'Wait for request to finish
Do While oXMLHTTP.readyState <> 4
DoEvents
Loop
'Returns the results as a byte array
oResp = oXMLHTTP.ResponseBody
'Create a local file and save result to it
vFF = FreeFile
If Dir(vLocalFile) <> "" Then Kill vLocalFile
Open vLocalFile For Binary As #vFF
Put #vFF, , oResp
Close #vFF
Set oXMLHTTP = Nothing
End Function
Edited to add Code Tags. (The # button)