Frage: Mehrere Dateien sollen aus dem Internet in einen bestimmten Ordner geladen werden (PNG, ZIP, PDF, XLS). Der Ordner soll ohne Nachfrage angelegt werden, wenn er nicht vorhanden ist. Die Dateien sollen lokal den gleichen Namen tragen den sie auch im Internet haben. Wie geht das?
Multiple files should be loaded from the Internet to a specific folder (PNG, ZIP, PDF, XLS). The folder should be created without asking if it is not present. The files are locally the same names they have in the internet. How does it work?
Hier noch eine Beispieldatei / Here's a sample file:
API - Ordner anlegen - Dateien aus dem Internet laden...[XLS 50 KB]
Multiple files should be loaded from the Internet to a specific folder (PNG, ZIP, PDF, XLS). The folder should be created without asking if it is not present. The files are locally the same names they have in the internet. How does it work?
Hier noch eine Beispieldatei / Here's a sample file:
API - Ordner anlegen - Dateien aus dem Internet laden...[XLS 50 KB]
'--------------------------------------------------------------------------
' Module : Module1
' Author : Case (Ralf Stolzenburg)
' Date : 26.04.2013
' Purpose : Ordner erstellen - Dateien aus dem Internet laden...
'--------------------------------------------------------------------------
OptionExplicit
PrivateDeclareFunctionMakeSureDirectoryPathExists_
Lib"imagehlp.dll"(ByValPfadAsString)AsLong
PrivateDeclareFunctionDeleteUrlCacheEntryLib"wininet"Alias_
"DeleteUrlCacheEntryA"(ByVallpszUrlNameAsString)AsLong
PrivateDeclareFunctionURLDownloadToFileLib"urlmon"_
Alias"URLDownloadToFileA"(_
ByValpCallerAsLong,_
ByValszURLAsString,_
ByValszFileNameAsString,_
ByValdwReservedAsLong,_
ByVallpfnCBAsLong)AsLong
' Pfad evtl. anpassen - abschliessenden Backslash NICHT vergessen!!!
' Ordner wird automatisch angelegt, wenn er nicht vorhanden ist
ConststrBackupAsString="C:\Temp\"
PublicSubGetFiles()
OnErrorGoToFin
LoadFiles"http://www.comburg.de/blog/files/Download.pdf"
LoadFiles"http://www.comburg.de/blog/files/XCOPY_and_more.zip"
LoadFiles"http://www.comburg.de/blog/files/WMI.xls"
LoadFiles"http://www.comburg.de/blog/files/Local_Window.png"
Fin:
IfErr.Number<>0ThenMsgBox"Error: "&_
Err.Number&" "&Err.Description
EndSub
PublicSubLoadFiles(ByValstrURLAsString)
DimlngTMPAsLong
CallDeleteUrlCacheEntry(strURL)
MakeSureDirectoryPathExistsstrBackup
lngTMP=URLDownloadToFile(0,strURL,strBackup&_
Mid(strURL,InStrRev(strURL,"/")+1),0,0)
EndSub