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
|
On Error GoTo ERREUR
Dim fso As Object
Dim strDest As String
Select Case CurrentProject.FileFormat
Case 2 'acFileFormatAccess2
GoSub MDB
Case 7 'acFileFormatAccess95
GoSub MDB
Case 8 'acFileFormatAccess97
GoSub MDB
Case 9 'acFileFormatAccess2000
GoSub MDB
Case 10 'acFileFormatAccess2002
GoSub MDB
Case 12 'acFileFormatAccess12
GoSub ACCDB
End Select
'Instanciation du FSO
Set fso = CreateObject("Scripting.FileSystemObject")
'Copie de la bdd
fso.CopyFile CurrentProject.FullName, strDest, True
'Purge du fso
Set fso = Nothing
'-----------------------------------------------
ERREUR:
Exit Sub
'---
MDB:
strDest = CurrentProject.Path & "\" & _
Left(CurrentProject.Name, Len(CurrentProject.Name) - 4) & _
".bak." & Right(CurrentProject.Name, 3)
Return
'---
ACCDB:
strDest = CurrentProject.Path & "\" & _
Left(CurrentProject.Name, Len(CurrentProject.Name) - 6) & _
".bak." & Right(CurrentProject.Name, 5)
Return |
Partager