A common way of compacting an Access database is to automate the menu
choice.
CommandBars("Menu Bar").Controls("Tools").Controls("Database utilities"). _
Controls("Compact and repair database...").accDoDefaultAction
The problem with doing this in Excel is that CommandBars refers to the
Excel object model rather than the Access object model.
A reference to the Access model is required and the command needs to be
changed to indicate that it refers to the Access model.