Download File from Internet (link on field) and save it(link on field).

Ucramos

New member
Local time
Today, 23:01
Joined
Jul 24, 2011
Messages
2
Hi.
I don´t have a lot of experience using VBA but i think this is the only way to do what i want.

I have a form called "Produtos"
in that form i have 2 fields that i want to use.
"FotoSitePNG" has the full link to a file i want to download like: fullwebsite/image01.png
"FotoLocalPNG" has the full link to the dir and file name i want to download to like: d\images\image01.png

These links vary with every field on the table, so i wanted to do something like: =downloadfile ([FotoSitePNG], [FotoLocalPNG])

I´ve tried every tip that i found on google, but i can´t get any to work.

Please help.
 
Hi.. :)

Use this procedure..:

Code:
Private Declare 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
    
Sub Downloadfile(URLFile As String, strSavePath As String)
    Dim ext As String
    Dim buf, ret As Long
    buf = Split(URLFile, ".")
    ext = buf(UBound(buf))
    strSavePath = FotoLocalPNG
    ret = URLDownloadToFile(0, URLFile, strSavePath, 0, 0)
    If ret = 0 Then
        MsgBox "Download has been succeed!"
    Else
        MsgBox "Error"
    End If
End Sub

use is..:

Code:
Call Downloadfile(FotoSitePNG, FotoLocalPNG)
 
Thank you :)
 

Users who are viewing this thread

Back
Top Bottom