I have an Excel workbook that I need to put some VBA code into. Unfortunately, our security policies are to disable macros with notification.

However, when I put the code into the Workbook_Open() event, it isn't triggered when I tell it to enable the content.

Can anyone assist?

  • 1
    Have you tried adjusting the settings, closing Excel, and then opening your workbook? – Excellll Oct 21 '11 at 15:13

I think you have to sign the macro: http://office.microsoft.com/en-us/excel-help/about-macro-security-HP003084611.aspx

  • I don't know that that's it or not. I can run macros, but there doesn't seem to be a workbook or worksheet event that fires when I choose to enable the macros in the security dialog. – Jason Oct 21 '11 at 13:56
  • If the macro security level is Medium, user is prompted to enable or disable unsigned macros. If macro is signed, it will run without prompt. – ma81xx Oct 21 '11 at 16:08

Not sure of the visibility of this file from the standpoint of your scenario (code needs to run for users within your company's network, code need to run when file is sent to outside vendors, etc.) but you could create a folder somewhere safe, and add it to Excel's Trust Center". Any folder defined there will allow for macros to run automatically without needing to be signed. BUT - doing this could skirt around the reasons Microsoft set up security in this manner; Namely, to keep potentially malicious code from being executed on a device.

If this vba code just needs to be able to be run for folks 'in the office', then such a setup should be no problem; Just create a folder specifically for this file, and add that single file to Excel's Trust Center. I say create a folder for the file so that the Directory added to the trust center has as narrow a focus on where code can be automatically run.

To add such a folder to the Trust Center, Click on the Orb in the upper left-hand corner and choose ExcelOptions --> Trust Center (in left column) --> Trust Center Settings (in main section) --> Trusted Locations (left column again). Here you will find the list of locations where code will automatically run. Simply click the 'Add New Location' button and browse to your folder to add it. Now place your excel file(s) there. Now when they are opened, the Workbook_Open event should fire immediately.

Hope this helps, Nim

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.