Results 1 to 6 of 6
  1. #1
    Join Date
    May 2007
    Posts
    27

    Unanswered: Passing parameters from command line to msaccess macro

    Hi,

    My first post! Please don't kill me for asking something that is likely very obvious, but that I'm missing ...

    I would like to start access from command line, running a macro when the mdb starts, and pass a parameter to that macro, straight from the command line. Something like this:

    "C:\Program Files\Microsoft Office\Office11\msaccess.exe" "c:\test.mdb" /x Macro_access_start "Hello world"

    The macro "Macro_access_start" would start a function using "RunCode" that would the use the parameter ("Hello world") to for instance show a msgbox or what not.

    Is this possible? How do I reference the parameter from the Macro?

    Thanks!

  2. #2
    Join Date
    Sep 2006
    Posts
    265
    Create a shortcut to Test.mdb and in Tools Startup you can put a form and create a macro autoexec to do the rest.

    Simon

  3. #3
    Join Date
    May 2007
    Posts
    27
    Hi Simon,

    Thanks for your reply. Unless I am mistaken, you are describing how to automatically run a macro from the command line. I know how to do that using the /x switch, which is the same, right?

    However, not only do I want to run a macro automatically, I want to pass a parameter to it, straight from the command line. How do I do that?

  4. #4
    Join Date
    Sep 2006
    Posts
    265
    I superceded this approach with a link to a MDE file that contains a full Menu system and dumped Macros completely however once you created your macro right click Create Short Cut.

    I personally I would persevere with Macros and convet them into VB. Even if you don't know how try using existing Macros an converting them. Once you get the hang of VB you will understand why they are so much better.

    Simon

  5. #5
    Join Date
    May 2007
    Posts
    27
    Hi Simon,

    I understand that VB is a much more complete language, but I don't have a license on my work machine (have done VB programming at home, so I hear you!).

    Back to the question though. Is it possible to pass parameters? I can't have a gui in this application, because it has to run completely automated, hence my need to pass these parameters.

  6. #6
    Join Date
    Sep 2006
    Posts
    265
    I believe so but I never tried to as this fuctionality I keep inside the application. However look at:

    http://support.microsoft.com/kb/209207

    There are modules that perform the VB - you don't need a license but there is an extra help file that you need to load though.

    Simon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •