Option Explicit
Option Compare Database

Public Function MyCompactMyDatabases() As Byte
Dim myCompactDB As MC_CompactDB

    
On Error GoTo ErrHandler:
    
    
'//Create the CompactDB class
    Set myCompactDB = New MC_CompactDB
    
    
'//Set any defaults as needed
    myCompactDB.DefaultBackupFolder = "xBackups"
    
myCompactDB.DefaultBackupRetention = 3
    
myCompactDB.DefaultLogFilePath = "C:\myTemp\log.txt"
    
myCompactDB.VerboseLogging = True
  
    
'-----------------------------------------------------
    '//My databases to compact
    myCompactDB.addDB "G:\DAT\TestDB3.mdb"
    
myCompactDB.addDB "G:\DAT\TestDB4.mdb", "DB4_BAK", , 8 '//different backup folder; backup retention set to 8
    myCompactDB.addDB "G:\DAT\TestDB5.mdb", , , 0 '//Backup retention set to 0 (no backups saved)

    
'//My monthly databases to compact (compact this DB on last Friday of every month)
    If VBA.Weekday(Date) = vbFriday And myCompactDB.EOMWeek() Then
        
myCompactDB.addDB "G:\DAT\TestDB6.mdb"
    
End If
    
'-----------------------------------------------------
    
    
'//Do Compacts
    MyCompactMyDatabases = myCompactDB.MC_CompactDatabases()
    
    
'//Clean up
    Set myCompactDB = Nothing
    
    
'//Note 2011-06-24:
    '  to email your log, see instructions at
    '  http://www.everythingaccess.com/tutorials.asp?ID=112
    '  (I have used this email routine with Access 2003 and Outlook2003/2007)
    
My_Exit:
Exit Function

ErrHandler:
MyCompactMyDatabases = 1
Resume My_Exit

End Function