YasserKhalil
Well-Known Member
Hello everyone
I have found the following code
But I got an error like that
Any help please?
I have found the following code
Code:
Sub Test()
Dim strPath As String
strPath = ThisWorkbook.Path & "\websitelogo.png"
Call SaveWebFile("http://www.bettersolutions.com/websitelogo.png", strPath)
ActiveSheet.Pictures.Insert strPath
Kill strPath
End Sub
Public Function SaveWebFile(ByVal vWebFile As String, ByVal vLocalFile As String) As Boolean
Dim oXMLHTTP As MSXML2.XMLHTTP
Dim i As Long
Dim vFF As Long
Dim oResp() As Byte
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
oXMLHTTP.Open "GET", vWebFile, False
oXMLHTTP.send
Do While (oXMLHTTP.readyState <> 4)
DoEvents
Loop
oResp = oXMLHTTP.responseBody
vFF = FreeFile
If Dir(vLocalFile) <> "" Then
Kill vLocalFile
End If
Open vLocalFile For Binary As #vFF
Put #vFF, , oResp
Close #vFF
Set oXMLHTTP = Nothing
End Function
But I got an error like that
Any help please?