Tough luck! Command compact only works for another, closed
database, not the one it's run from (this applies to both
Macro and VBA).
The only alternative I know of is to use SendKeys to run
it from the menu... but SendKeys can be tricky, and should
be avoided to the extent possible.
When faced with the same problem, I ended up writing a
small VB application (self-contained .exe) which first
compacts the database and then opens it... but you'll need
VB for this, VBA is not capable of producing executable
files.
Nikos Y. (nyannaco at in dot gr).