1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| Option Compare Database
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
Function TelechargerFichier()
DossierDestination = "C:\Saveurs des Prairies\Downloads\"
NomFichier = "MAJ_SDP.zip"
FichierSource = "https://www.dropbox.com/s/9k0u4dwxlm4m73q/MAJ_SDP.zip?dl=0"
returnValue = URLDownloadToFile(0, FichierSource, DossierDestination & NomFichier, 0, 0)
MsgBox "Telechargement termine"
End Function
Function MAJ()
DoCmd.TransferDatabase acImport, "Microsoft Access", "C:\Saveurs des Prairies\MAJ\MAJ_SDP.accdb", acTable, "T_Pdt", "T_Pdt", 0, 1
End Function
Public Function UnzipTo(ByVal zipFile As String, ByVal unzipPath As String) As Boolean
On Error GoTo catch
Dim oShell As Object, bExist As Boolean, sErr As String
If zipFile <> vbNullString And Right$(zipFile, 1) <> "\" Then bExist = (Dir(zipFile) <> vbNullString)
If Not bExist Then
sErr = "le fichier '" & zipFile & "' est introuvable..."
ElseIf unzipPath <> vbNullString And _
Dir(unzipPath & "\", vbDirectory) <> vbNullString Then
Set oShell = CreateObject("Shell.Application")
oShell.Namespace(CVar(unzipPath)).CopyHere oShell.Namespace(CVar(zipFile)).items
UnzipTo = True
Else
sErr = "Le répertoire '" & unzipPath & "' n'existe pas..."
End If
fin:
If Not oShell Is Nothing Then Set oShell = Nothing
If UnzipTo Then
MsgBox "Décompression réussie du fichier '" & zipFile & _
"' dans le répertoire '" & unzipPath & "'", vbInformation, "UnzipTo"
Else
MsgBox sErr, vbExclamation, "UnzipTo"
End If
Exit Function
catch:
sErr = "Une erreur s'est produite..." & vbCrLf & "Erreur n°" & Err.Number & vbCrLf & "Description" & Err.Description
Resume fin
End Function |
Partager