compact Access DB from Excel

G

Guest

I'm using the following code in Excel to allow users to compact their Access
database.

vDB = ActiveWorkbook.Sheets("Info").Range("C5")

Set AppAcc = New Access.Application
AppAcc.Visible = False
AppAcc.OpenCurrentDatabase vDB

DoCmd.SetWarnings False

AppAcc.CommandBars("Menu Bar").Controls("Tools").Controls("Database
utilities"). _Controls("Compact and repair database...").accDoDefaultAction

DoCmd.SetWarnings True
AppAcc.Visible = True
AppAcc.Quit acQuitSaveNone

Set AppAcc = Nothing

I would like to do a couple of things differently:

(1) I would like to change the directory the users will see on the dialog
box instead of the path and directory where the macro resides.

(2) I would like to display a message if the users selects the "cancel"
option instead of saving the database.

Is it possible to do make either one of these changes? Any help getting
started would be appreciated. Thanks for the help...
 
G

Guest

one solution?, command line approach

CreateObject("WScript.Shell").Run "MSAccess " & _
Chr(34) & ActiveWorkbook.Sheets("Info").Range("C5") & _
Chr(34) & "/runtime /compact", 0, True

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top