Welcome to FreeSoftwareServers Confluence Wiki

Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _
    Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
    ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Public Sub DownloadImageURL(ImgURLStr As String, FullFilePathStr As String)
 URLDownloadToFile 0, ImgURLStr, FullFilePathStr, 0, 0
End Sub
Public Sub ImportPicturefromURL(ImgURLStr As String, FullFilePathStr As String)
 Call DownloadImageURL(ImgURLStr, FullFilePathStr)
 ActiveSheet.Pictures.Insert (FullFilePathStr)
 Kill FullFilePathStr
End Sub
Public Sub TestImportPicture()
 Dim ImgURLStr As String, DLPathStr As String, FileNameStr As String, FullFilePathStr As String
 ImgURLStr = "http://url"
 DLPathStr = Environ("TEMP") & "\"
 FileNameStr = "temp.jpg"
 FullFilePathStr = DLPathStr & FileNameStr
 Debug.Print FullFilePathStr
 Call ImportPicturefromURL(ImgURLStr, FullFilePathStr)
End Sub
  • No labels