Run Access Macro from command line

Posted on 2012-09-06
Last Modified: 2012-09-11
Can I run an Access (2010) macro from command line? The idea is to have a batch script to execute the command every day.
Question by:kris_sk2012
    LVL 19

    Accepted Solution

    This is info for Access 2007.  2010 is likely the same:

    The example given there is:
    msaccess.exe /ro "c:\MyFolder\MyDatabase.accdb" /x MyMacro
    LVL 39

    Expert Comment

    Usually you should use full path to msaccess.exe and ro is read only.
    Sample cntent of cmd file:
    "c:\Program Files\Microsoft Office\Office14\MSACCESS.EXE"  "\\MyServer\DB\test.accdb" /X M1

    Open in new window


    Author Comment

    Thanks  - but I keep getting warning messages and they are interrupting the command execution. Any way to suppress them.
    Also Access doesn't close automatically and stays open after the command executes. I need it to Close.
    LVL 39

    Expert Comment

    You should add DB folder to trusted and close Access in the end of your macro
    Test sample with macro M1
    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    <have a batch script to execute the command every day>
    Is this command a mystery?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now