Running a Macro from Command Line

C

Chris

I am running Access 2002 and I am trying to run a macro
from a command line. I have figured out the command line
tags to accomplish this, but every time I run the command
a new instance of Access is opened. I was wondering if
anyone knew of a way to start a macro from command line
so that if the correct database is already open, it will
use that instance instead of opening another one?
thanks, chris
 
6

'69 Camaro

Hi, Chris.

You can't do this from the command line, unless you write an application or
script that does this for you, and then call *that* application or script
from the command line. And since you are seeking to automate something in
Access via a Macro, I suspect that you aren't inclined to go that convoluted
route.

I also suspect that you aren't really typing this command on a command line
in the DOS shell or the Windows Start -> Run command text box, either. I
suspect that you are using a Windows shortcut to run the command that opens
the Access database where you want the Macro to execute.

True?

If so, and you don't have Access security implemented, then an Access
shortcut, not a Windows shortcut, will solve the problem. The Access
shortcut will determine whether an instance of the database application is
already open and, if it is, then it will execute the Macro for you. If the
correct database application is not already open, then Microsoft Access will
launch, open the database file, then execute your Macro.

To create an Access Macro shortcut:

1.) Open the database that contains the Macro you want to execute.
2.) Open the database window to view the list of Macros.
3.) Right-click with your mouse on the Macro (the one that you wanted to
execute from the command line).
4.) On the pop-up menu, select "Create Shortcut..." and use the "Create
Shortcut" dialog window to save the shortcut to your desktop (the default)
or in some directory on your hard drive.

When you execute the shortcut by double-clicking on it, Access will execute
the Macro immediately if the correct database file is already open on your
computer, or else a new instance of Access will open your database file,
then execute your macro.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
 
G

Guest

Gunny,
As a point of detail, I was using the command line to
start access and not a windows shortcut. That said, I
took your advice on the Access shortcut and it worked
great. Thanks alot for your help on this.
chris
 

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