[转]How to enable macros in Excel 2016, 2013, and 2010

本文转自:https://www.ablebits.com/office-addins-blog/2014/07/22/enable-macros-excel/#always-run-macros

This tutorial teaches how to enable macros in Excel 2010-2013. You'll also find step-by-step instructions showing how to disable macros in Excel or turn them on via Message bar and Backstage view. In addition you'll find a tip to run a macro even if all macros are disabled and get a link to a piece of code that gets users enable macros in a workbook.

First off, I'd like to share a brief intro to Excel macros and security risk linked to enabling them. A macro is a series of commands assembled together and designed to automate frequent routine tasks in Excel. You can run macros any time to perform certain actions.

Many macros are created using Visual Basic for Applications, or VBA. Lots of Excel users can record simple macros to streamline their work with spreadsheets. Developers create codes that are more complicated.

When enabling a macro in Excel that was written by someone else, you need to remember that it can carry a potential security risk. A person with malicious intent, like hacker, can make a destructive macro to spread a virus on your PC or network.

Read on to find detailed descriptions of macro settings, steps to enable Excel macros and save a macro-enabled workbook. You can also click any of the links below to get straight to the point.

How to enable macros in Excel from the Message Bar

If you open an Excel document that contains macros, you'll see the yellow Message Bar with a shield icon and the Enable Content button.

If you are sure, the macros are from a trustworthy source, just press the Enable Content button on the bar.

Press the Enable Content button on the Message Bar
The file will be opened as a trusted document and the security warning will disappear.

Excel - enable macros via the Backstage view

You can also enable macros in Excel using the Microsoft Office Backstage view. You can see the yellow Message Bar if you click the File tab.

  1. Click on the File tab.
    Click the File tab
  2. You'll see the yellow Security Warning area. Click Enable Content.
    In the Security Warning area, click Enable Content
  3. You will see 2 features: Enable All Content and Advanced Options. Select Enable All Content to always make the document's active content available.

The current Excel file will become a trusted document and all macros will be enabled.
Select Enable All Content to always make the document's active content available

How to always run macros for a trusted worksheet

If you create and share workbooks with macros you may want to avoid getting the security message every time. If you get all your workbooks only from reliable sources, you can choose to instantly run all macros for all publishers. Below you'll see how to enable all macros in Excel by default.

  1. Go to File -> Options -> Trust Center and press the Trust Center Settings ... button.
    Go to File -> Options -> Trust Center and press the Trust Center Settings ... button

     

    Tip. You can also click on the Trust Center Settings link on the Security Warning.
    Click on the Trust Center Settings link
  2. You will see the Trust Center window. Select the Macro Settings option.
    Select the Macro Settings option
  3. Select the radio button Enable all macros (not recommended, potentially dangerous code can run).

From now on all macros will run without warning.

Please note that this setting makes your computer open to viruses. You should be sure you get all workbooks with macros only from the trusted publishers.

Adjust macro settings on the Trust Center window

You can find all macro settings on the Trust Center window. These settings let you adjust the way you want to work with macro-enabled workbooks.

Follow the steps from How to always run macros for a trusted worksheet to get the Trust Center window.

Please see all the macro settings explained below:

  • Disable all macros without notification. Macros and security alerts regarding them get turned off.
  • Disable all macros with notification. If you select this radio button, macros will be disabled, but security alerts will appear if there are macros in a file. It lets you enable macros in Excel depending on the source.
  • Disable all macros except digitally signed macros. In this case, macros are turned off, security alerts appear and digitally signed by a trusted publisher macros run. If you have not trusted the publisher, you are offered to enable the signed macro and trust the publisher.
  • Enable all macros (not recommended, potentially dangerous code can run). All macros run without warning. Please note that this setting makes your computer open to viruses.
  • Trust access to the VBA project object model. This checkbox forbids or allows programmatic access to the Visual Basic for Applications (VBA) object model from an automation client. This security setting is for the code that computerizes an Office program and manipulates VBA environment and object model. For automation clients to access the VBA object model, the user running the code must grant access. You need to tick the check box to give access.

Run a macro even if all macros are disabled

Say the setting Disable all macros without notification is turned on your PC, but you need to run certain macro here and now. If you have Excel 2007-2013, you can enable macros even if your security settings don't allow this. The point is that Excel sees certain locations as trusted zones. This means if you store your macro-enabled files there, the security check can be omitted and the macro will run.

Please see the list of these trusted locations below:

Program Files\Microsoft Office\Templates

Program Files\Microsoft Office\Office12\Startup

Program Files\Microsoft Office\Office12\Library

Program Files\Microsoft Office\Office12\XLSTART

You can add any location on your PC to the trusted zone, by following the steps below:

  1. In Excel navigate to the File tab -> Options -> Trust Center -> Trust Center Settings -> Trusted Locations.
    In Excel navigate to the File tab -> Options -> Trust Center -> Trust Center Settings -> Trusted Locations
  2. Click on the Add new location button to see the Microsoft Office Trusted Location dialog box.
    See the Microsoft Office Trusted Location dialog box
  3. Click Browse to search for the needed place on your PC.
    Click Browse to search for the needed place on your PC
Note. Before adding any location to trusted, make sure it's really safe since such location can be attacked by hackers.

How to save a macro in a workbook

Macros need you to save the files in a new macro-enabled workbook format. This type adds security warning to your file. If you don't choose the correcttype, the command will not be kept. Below you'll find how to save a macro-enabled Excel document:

  1. Navigate to File -> Save As and browse for the necessary location on your PC.
  2. Click on the Save as type: arrow and select the Excel Macro-Enabled Workbook from the list of types.
    Select the Excel Macro-Enabled Workbook from the list of types
  3. Click Save to keep the results.

If you forget to select the type of Macro Enabled Workbook, you'll get a warning message notifying that the macro will not be saved:
Get a warning message notifying that the macro will not be saved

Click No if you need to keep the macro.

How to disable macros in Excel 2010-2013

Suppose, you only proofread the files and don't need macros enabled on your PC. You get documents from various sources and prefer to set your security settings to the highest level. Since some macros can be potentially dangerous, you can disable them all using the Trust Center options.

  1. Follow the steps from How to always run macros for a trusted worksheet to get the Trust Center window.
  2. Select the Disable all macros without notification or Disable all macros with notification radio button. If you go for the first option, you will not know if there are any macros in the current file. The second button lets you identify Excel workbooks that contain macros.

Use special code to make users enable macros in a workbook

The code from this article forces a user to enable macros in a workbook. This code hides all sheets until the macro is enabled. It also adds a warning sheet that alerts the user to run macros. As soon as a user turns the commands on, the warning sheet is hidden and all other content is shown.

  1. Add the code to your workbook.
  2. Create a new sheet named "Warning".
  3. Add a message on the worksheet asking the user to re-open the workbook and enable macros.
  4. Finally, save your workbook.

You may also be interested in

Check out Tutorial with Excel examples about Macros for some nice and simple samples to automate your daily spreadsheet tasks.

If you are starting to learn macros, read How to insert and run VBA code in Excel - tutorial for beginners.

That's all about enabling and disabling macros in Excel. Hope you've found the information helpful. Feel free to leave your questions in the comments below. Be happy and excel in Excel!

posted on 2019-07-30 17:38  freeliver54  阅读(1112)  评论(0编辑  收藏  举报

导航