Try putting this in a module.
You will need to set Source Path, Source File and Backup Path to suit your own
set up
HTH
David B
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Function BackupAndZipittoC()
'This function will allow you to copy a db that is open,
'rename the copied db and zip it up to anther folder.
'You must set a reference to the 'Microsoft Scripting Runtime' for the CopyFile
piece to work!
'Thanks to Ricky Hicks for the .CopyFile code also G Hudson
Dim fso As FileSystemObject
Dim sSourcePath As String
Dim sSourceFile As String
Dim sBackupPath As String
Dim sBackupFile As String
sSourcePath = "C:\Hoofprint\"
sSourceFile ="Stock_be.mdb"
sBackupPath = "C:\Hoofprint\Backups"
sBackupFile = "Backupstock_" & Format(Date, "mmddyyyy") & "_" & Format(Time,
"hhmmss") & ".mdb"
Set fso = New FileSystemObject
fso.CopyFile sSourcePath & sSourceFile, sBackupPath & sBackupFile, True
Set fso = Nothing
Dim sWinZip As String
Dim sZipFile As String
Dim sZipFileName As String
Dim sFileToZip As String
sWinZip = "C:\Program Files\WinZip\WinZip32.exe" 'Location of the WinZip program
sZipFileName = Left(sBackupFile, InStr(1, sBackupFile, ".", vbTextCompare) - 1)
& ".zip"
sZipFile = sBackupPath & sZipFileName
sFileToZip = sBackupPath & sBackupFile
Call Shell(sWinZip & " -a " & sZipFile & " " & sFileToZip, vbNormalFocus)
MsgBox "Backup is proceeding. This routine can take up to 10 seconds to
complete"
Sleep 10000
If Dir(sBackupPath & sBackupFile) <> "" Then Kill (sBackupPath & sBackupFile)
Beep
MsgBox "Backup was successful and saved @ " & Chr(13) & Chr(13) & sBackupPath &
Chr(13) & Chr(13) & "The backup file name is " & Chr(13) & Chr(13) &
sZipFileName, vbInformation, "Backup Completed"
End Function
Rob <ch*******@yahoo.com> wrote in message
news:60**************************@posting.google.c om...
Hello,
I am trying to zip a folder(this folder contains several
files), from access application.This is as a part of back up
procedures which I am writing.I have written the timer program for
other functions .I wrote a code to utilize the WinZip exe.While it
zips the folder ,the folder does not exist after the zip procedure.I
want some help in tuning this code so that the original folder is
still retained in addition to the zipped one.Also ,I need to place a
copy of this zipped folder to another drive.Any help greatly
appreciated.
Thanks,
Rob