0

I am using a batch file to launch Outlook and Excel 2007 as follows:

start "" "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE"
start "" "C:\Program Files\Microsoft Office\Office12\EXCEL.EXE"
"C:\Users\username\Documents\Productivity\gtd_active.xlsm"

Both Outlook and Excel contain macros I must enable each time and I am hoping to do this via the command line.

I have tried the following with Excel:

start "" "C:\Program Files\Microsoft Office\Office12\EXCEL.EXE"
"C:\Users\username\Documents\Productivity\gtd_active.xlsm" /mtestMeStartup

to try and start a macro (this does not work, I am still prompted with the "Enable Macros" warning). I had hoped this would automatically trigger the "enable macros" option.

How do I pass an argument (or otherwise) to launch Excel/Outlook from a batch file and automatically enable macros?


Note: this link suggests this might not be possible... :\

R3uK
  • 14,417
  • 7
  • 43
  • 77
enderland
  • 13,825
  • 17
  • 98
  • 152
  • Would you be able to use VBScript instead? If so: http://stackoverflow.com/questions/2050505/way-to-run-excel-macros-from-command-line-or-batch-file – Francis Dean Feb 22 '13 at 14:46
  • 1
    What would be the point of the macro security if you could get around it with a macro? – Fionnuala Feb 22 '13 at 16:32
  • @Remou I'm not actually interested in calling a specific macro. I'm interested in being able to open the application and avoid having to click through the "enable macros" every time. – enderland Feb 22 '13 at 16:36

1 Answers1

2

You are asking about disabling macros through code, which would make the security of very little use.

You can self-sign your code ( http://office.microsoft.com/en-us/excel-help/security-iii-sign-your-own-macros-for-stronger-security-RZ010238036.aspx?section=5 ), and I believe you can use a trusted location. I like self-signed code, for the most part, but it is specific to the computer you create the cert on.

Fionnuala
  • 90,370
  • 7
  • 114
  • 152