MS Access - The RunMacro action was canceled.

By Ryan
Picture of the author
Published on

I was trying to run an msaccess macro using Windows XP scheduled tasks. It wasn't working. It gave me the following error when it tried to close access after the macro was finished:

"The RunMacro action was canceled. You used a method of the DoCMD object to carry out an action in Visual Basic, but then clicked Cancel in a dialog box. For example, you used the Close method to close a changed form, then clicked Cancel in the dialog box that asks if you want to save the changes you made to the form."

My server was running macro's fine, so I looked at the Task Properties and noticed they were different.

The solution:

Why was there a problem? Apparently making a scheduled task run an actual macro shortcut (.MAM) file is the wrong way to do it. I'm not sure how to do it the other way using a wizard, but I'll show you how to change the scheduled task to run the proper way.

The Wrong Way

Run: "C:\path_to_macro\macro_name.MAM" Start in: "C:\path_to_macro"

The Right Way

Run: "C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE" "\pathtodatabase.accdb" /x "Macro Name" Start in: "C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft Office"