Access 2007 Automation

Piglette
Lounger
Posts: 35
Joined: 20 Feb 2010, 05:05

Access 2007 Automation

Post by Piglette »

I have a large project that is basically: Open an .accdb - Run 3 macros from the Switchboard - Quit. We are talking many files, each of which could take hours to run.

I have automated the task up to a point using AutoHotkey. I would be home free for unattended operation if Access would open with the Switchboard active and the Navigation Pane minimized. Are there any preferences in Access to accomplish this?

Alternatively, could this be done by an Access "upon Open" macro?

Thanks

Lukas

Mark L
3StarLounger
Posts: 331
Joined: 11 Feb 2010, 03:55
Location: Land O Lakes, FL

Re: Access 2007 Automation

Post by Mark L »

I assume it is still available in A2007 (I'm too lazy to check), but you used to be able to specify a command line option when starting Access. Any text follow the /cmd could be accessed via the Command function in code. You could check this in your startup form, then proceed merrily on your way.
Mark Liquorman
Land O Lakes, FL
see my website http://www.liquorman.net for Access Tips and Tricks, and for my Liquorman Utilities.

User avatar
HansV
Administrator
Posts: 78523
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 Automation

Post by HansV »

Some options:

1) You can click the Office button, click Access Options and then Current Database to specify how the database opens:
- In the Display Form dropdown, you can set the Switchboard to be opened automatically.
- You can clear the check box "Display Navigation Pane".

2) If you create a macro named AutoExec in the database, it will be run automatically when the database is opened. You can call any macro command in this macro, including calling other macros and quitting Acccess.

3) You can open the database with the /x switch to run any macro (which in its turn can call other macros, etc.). For example:

msaccess.exe "C:\My Folder\My Database.accdb" /x MyMacro
Best wishes,
Hans

Piglette
Lounger
Posts: 35
Joined: 20 Feb 2010, 05:05

Re: Access 2007 Automation

Post by Piglette »

Thanks! Works like a charm.

Does Access support macros that are hidden from the user (would not show on the Switchboard), but can still be called with the /X switch?

We have to support both manual control by users and automated control by an external program (AutoHotkey). While coordinate-based mouse clicks on the Switchboard do work fine in a controlled environment (I am running a bunch of dedicated machines all set up exactly the same), I much prefer to call the first macro from the command line and then have that call the next, ... and finally have the last macro (database export) quit Access.

Thanks again for your help

Lukas

User avatar
HansV
Administrator
Posts: 78523
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 Automation

Post by HansV »

The switchboard only contains links to the forms, reports and macros that you want. The database can contain many more forms, reports and macros. So the answer to your question is yes.
Best wishes,
Hans

Piglette
Lounger
Posts: 35
Joined: 20 Feb 2010, 05:05

Re: Access 2007 Automation

Post by Piglette »

Thanks again!