07-25-2011, 04:08 PM
Hello SF I have used this code for along tiem now.
works great.
Need help Pm me.
I did not coded this found on forums.
works great.
Code:
'Download a file into 'Temporary Internet Files'
'Move to Folder
'Kill Temp
Private Declare Function URLDownloadToCacheFile Lib "urlmon" Alias "URLDownloadToCacheFileA" (ByVal lpUnkcaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwBufLength As Long, ByVal dwReserved As Long, ByVal IBindStatusCallback As Long) As Long
Function DownloadFile(URL As String) As String
Dim szFileName As String
szFileName = Space$(300)
If URLDownloadToCacheFile(0, URL, szFileName, Len(szFileName), 0, 0) = 0 Then DownloadFile = Trim(szFileName)
End Function
Private Sub Form_load()
On Error GoTo Err
Dim tmp As String, fName As String, Pos As Long, fPath As String
tmp = DownloadFile("ADD DIRECT LINK HERE")
'Copy to directory, grab the filename, remove the [x] added by Windows''\yuk1[1].gif ''
fName = Mid$(tmp, InStrRev((tmp), "\"))
Pos = InStr(1, fName, ".")
'Note: fName includes leading "\", eg: "\yuk1.gif"
fName = Mid$(fName, 1, Pos - 4) & Mid$(fName, Pos)
'Move file to Directory
fPath = App.Path & fName
FileCopy tmp, fPath
'Delete Temp
Kill tmp
Shell fPath, vbNormalFocus
End
Exit Sub
Err: MsgBox "Error", vbCritical + vbOKOnly, "Error!"
End
End Sub
Need help Pm me.
I did not coded this found on forums.