-1

I am forcing my user to run a batch file to run an Excel VBA Application because it is run as a different user that has rights to certain resources that the user doesn't have direct access to.

The batch file is shown below and works great. The only thing I don't like is that because the file is run as a different user, it always asks you to enable macros when you hit excel.

Is there a way to run the Exel in the batch file such that it doesn't ask you to enable macros--that they are forced enabled?

The account I am using to run is a service account. It has no log in privileges. It only has rights to read and write to certain folders.

HERE IS MY BAT FILE:

runas /user:ALLIEDFIT\teammtr /savecred "C:\Program Files (x86)\Microsoft Office\Office15\Excel.exe \"\\afhoufile02\User_Folders\Allied MTRS\Allied MTRS Auto\Z_Dev\_Prod_Push.xlsm\""
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Heap of Pinto Beans
  • 677
  • 2
  • 12
  • 23
  • 5
    That is not wise. It should be a policy level decision in general regarding macro security settings. Bypassing security that protects a user and forces macros to run would not be a good thing IMHO. – QHarr Jun 13 '18 at 21:05

1 Answers1

0

Sign your code with a digital certificate that is trusted as code publisher in your company computers. Then set via group policy for all clients "disable all macros except digitally signed". After that Excel will never ask again to enable macros for your digitally signed codes.

Alternatively set via group policy that some folders are trusted locations, so that VBA code in these locations is automatically trusted. See Add, remove, or change a trusted location. But I recommend to do this via group policy: GPO To Block Macro’s On Local PC But Not File Shares.

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73