Command Line for Macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have been trying to open an access database using a command line. According
to the Access documentation the format should be /x macro. I am able to get
access to load using C:/Directory/filename.mdb but when I put
C:/Directory/filename.mdb /x Run where Run is my macro name it doesn't run my
macro. I am using Access 2000 on a windows XP machine.
 
Joshua said:
I have been trying to open an access database using a command line.
According to the Access documentation the format should be /x macro.
I am able to get access to load using C:/Directory/filename.mdb but
when I put C:/Directory/filename.mdb /x Run where Run is my macro
name it doesn't run my macro. I am using Access 2000 on a windows XP
machine.

Those are command line arguments for MSAccess.exe, not for an MDB file. By
that I mean if you want to use any of the optional comman line argumnets for
Access your command must point to MSAccess.exe and then supply the file name
to open as an additional argument. If your command line only points at the
file, then the command line arguments are not recognized. The format is
roughly...

"Full Path to MSAccess.exe" "Full path to MDB" /x Run
 
When using the command line, the switches are for the Msaccess.exe file, so
it has to be specified also.

"C:\Program Files\Microsoft Office\Office\Msaccess.exe"
"C:\Directory\FileName.mdb" /x Run

When you only type the name of the file, Windows uses it file association to
launch the application. If you open My Computer, go to Tools|Folder Options
then click on the File Types tab you will see where this is setup. Scroll
down to the mdb extension, click the Advanced button, highlight Open, then
click Edit. You will see that the command line given (DON'T change it unless
you know what you're doing) is

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" /NOSTARTUP "%1"

Click the Cancel button, NOT the Ok button, to close the dialogs. Using the
Cancel button will remove any accidental changes you may have made.

In the command line, %1 is replaced with the name and path of the file. As
you can see in the command line, the full path to the exe has been
specified, just as you need to do with your command line. This is why you
can specify just the name of a file and have it work, Windows supplies the
rest. However, if you need more than that, you'll need to do it all
yourself.
 
Back
Top