|
|
|
This page presents how to work with Microsoft Excel 2007 features and its redesigned interface. You may also visit our Excel Question page.
|
Change macro security settings in Excel
In Microsoft Office Excel, you can change the macro security settings to control which macros run and under what circumstances when you open a workbook. For example, you might allow macros to run based on whether they are digitally signed by a trusted developer.
For more information about macro security settings in Microsoft Office documents, see Enable or disable macros in Office documents.
In this article

Macro security settings and their effects
Change macro security settings
Using digital signatures

Macro security settings and their effects
The following list summarizes the various macro security settings. Under all settings, if antivirus software that works with 2007 Microsoft Office system is installed and the workbook contains macros, the workbook is scanned for known viruses before it is opened.
- Disable all macros without notification Click this option if you don't trust macros. All macros in documents and security alerts about macros are disabled. If there are documents that contain unsigned macros that you do trust, you can put those documents into a trusted location. Documents in trusted locations are allowed to run without being checked by the Trust Center security system.
- Disable all macros with notification This is the default setting. Click this option if you want macros to be disabled, but you want to get security alerts if there are macros present. This way, you can choose when to enable those macros on a case by case basis.
- Disable all macros except digitally signed macros This setting is the same as the Disable all macros with notification option, except that if the macro is digitally signed by a trusted publisher, the macro can run if you have already trusted the publisher. If you have not trusted the publisher, you are notified. That way, you can choose to enable those signed macros or trust the publisher. All unsigned macros are disabled without notification.
- Enable all macros (not recommended, potentially dangerous code can run) Click this option to allow all macros to run. Using this setting makes your computer vulnerable to potentially malicious code and is not recommended.
- Trust access to the VBA project object model This setting is for developers and is used to deliberately lock out or allow programmatic access to the VBA object model from any Automation client. In other words, it provides a security option for code that is written to automate an Office program and programmatically manipulate the Microsoft Visual Basic for Applications (VBA) environment and object model. This is a per user and per application setting, and denies access by default. This security option makes it more difficult for unauthorized programs to build "self-replicating" code that can harm end-user systems. For any Automation client to be able to access the VBA object model programmatically, the user running the code must explicitly grant access. To turn on access, select the check box.
Top of Page
Change macro security settings
You can change macro security settings in the Trust Center, unless a system administrator in your organization has changed the default settings to prevent you from changing the settings.
- On the Developer tab, in the Code group, click Macro Security.
Tip If the Developer tab is not displayed, click the Microsoft Office Button
, click Excel Options, and then in the Popular category, under Top options for working with Excel, click Show Developer tab in the Ribbon.
- In the Macro Settings category, under Macro Settings, click the option that you want.
Note Any changes that you make in the Macro Settings category in Excel apply only to Excel and do not affect any other Microsoft Office program.
Tip You can also access the Trust Center in the Excel Options dialog box. Click the Microsoft Office Button
, and then click Excel Options. In the Trust Center category, click Trust Center Settings, and then click the Macro Settings category.
Top of Page
Using digital signatures
The 2007 Office release uses Microsoft Authenticode technology to enable macro creators to digitally sign (digital signature: An electronic, encryption-based, secure stamp of authentication on a macro or document. This signature confirms that the macro or document originated from the signer and has not been altered.) a file or a macro project (macro project: A collection of components, including forms, code, and class modules, that make up a macro. Macro projects created in Microsoft Visual Basic for Applications can be included in add-ins and in most Microsoft Office programs.). The certificate that is used to create this signature confirms that the macro or document originated from the signer, and the signature confirms that the macro or document has not been altered.
After you install your digital certificate (digital certificate: Attachment for a file, macro project, or e-mail message that vouches for authenticity, provides secure encryption, or supplies a verifiable signature. To digitally sign macro projects, you must install a digital certificate.), you can sign files and macro projects.
Obtaining a digital certificate for signing
You can obtain a digital certificate from a commercial certificate authority (CA) (certificate authority (CA): A commercial organization that issues digital certificates, keeps track of who is assigned to a certificate, signs certificates to verify their validity, and tracks which certificates are revoked or expired.), or from your internal security administrator or information technology (IT) professional.
To learn more about certificate authorities that offer services for Microsoft products, see the list of Microsoft Root Certificate Program Members.
Creating your own digital certificate for self-signing
You can also create your own self-signing certificate by using the Selfcert.exe tool.
Note Because a digital certificate that you create isn't issued by a formal certificate authority, macro projects that are signed by using such a certificate are referred to as self-signed projects. Microsoft Office trusts a self-signed certificate only on a computer that has that certificate in your Personal Certificates store.
For more information about how to digitally sign a macro, see Digitally sign a macro project.
Top of Page
Related Office Online discussions
Read related questions and answers from other Microsoft Office customers.

See Also
Excel > Macros
Create or delete a macro
Excel 2007

Tags add macro; automate; disable macro; enable macros; macro; macro button; macro security; Script; unhide; vba

What are tags?
To automate a repetitive task, you can quickly record a macro (macro: An action or a set of actions that you can use to automate tasks. Macros are recorded in the Visual Basic for Applications programming language.) in Microsoft Office Excel. You can also create a macro by using the Visual Basic Editor (Visual Basic Editor: An environment in which you write new and edit existing Visual Basic for Applications code and procedures. The Visual Basic Editor contains a complete debugging toolset for finding syntax, run-time, and logic problems in your code.) in Microsoft Visual Basic to write your own macro script, or to copy all or part of a macro to a new macro. After you create a macro, you can assign it to an object (such as a toolbar button, graphic, or control) so that you can run it by clicking the object. If you no longer use a macro, you can delete it.
What do you want to do?

Record a macro
Create a macro by using Microsoft Visual Basic
Copy part of a macro to create another macro
Assign a macro to an object, graphic, or control
Delete a macro

Record a macro
When you record a macro, the macro recorder records all the steps required to complete the actions that you want your macro to perform. Navigation on the Ribbon is not included in the recorded steps.
Note The Ribbon is a component of the Microsoft Office Fluent user interface.
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
- To set the security level temporarily to enable all macros, do the following:
- On the Developer tab, in the Code group, click Macro Security.

- Under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
Note To help prevent potentially dangerous code from running, we recommend that you return to any one of the settings that disable all macros after you finish working with macros. For more information about how to change the settings, see Change macro security settings in Excel.
- On the Developer tab, in the Code group, click Record Macro.
- In the Macro name box, enter a name for the macro.
Note The first character of the macro name must be a letter. Subsequent characters can be letters, numbers, or underscore characters. Spaces cannot be used in a macro name; an underscore character works well as a word separator. If you use a macro name that is also a cell reference, you may get an error message that the macro name is not valid.
- To assign a CTRL combination shortcut key (shortcut key: A function key or key combination, such as F5 or CTRL+A, that you use to carry out a menu command. In contrast, an access key is a key combination, such as ALT+F, that moves the focus to a menu, command, or control.) to run the macro, in the Shortcut key box, type any lowercase letter or uppercase letter that you want to use.
Note The shortcut key will override any equivalent default Excel shortcut key while the workbook that contains the macro is open. For a list of CTRL combination shortcut keys that are already assigned in Excel, see Excel shortcut and function keys.
- In the Store macro in list, select the workbook where you want to store the macro.
Tip If you want a macro to be available whenever you use Excel, select Personal Macro Workbook. When you select Personal Macro Workbook, Excel creates a hidden personal macro workbook (Personal.xlsb) if it does not already exist, and saves the macro in this workbook. In Windows Vista, this workbook is saved in the C:\Users\user name\AppData\Local\Microsoft\Excel\XLStart folder. In Microsoft Windows XP, this workbook is saved in the C:\Documents and Settings\user name\Application Data\Microsoft\Excel\XLStart folder. Workbooks in the XLStart folder are opened automatically whenever Excel starts. If you want a macro in the personal macro workbook to be run automatically in another workbook, you must also save that workbook in the XLStart folder so that both workbooks are opened when Excel starts.
- In the Description box, type a description of the macro.
- Click OK to start recording.
- Perform the actions that you want to record.
- On the Developer tab, in the Code group, click Stop Recording
.
Tip You can also click Stop Recording
on the left side of the status bar.
Top of Page
Create a macro by using Microsoft Visual Basic
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
- To set the security level temporarily to enable all macros, do the following:
- On the Developer tab, in the Code group, click Macro Security.

- Under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
Note To help prevent potentially dangerous code from running, we recommend that you return to any one of the settings that disable all macros after you finish working with macros.
- On the Developer tab, in the Code group, click Visual Basic.
- If needed, in the Visual Basic Editor, on the Insert menu, click Module.
Note Modules are automatically created for all sheets in the workbook.
- In the code window of the module, type or copy the macro code that you want to use.
- To run the macro from the module window, press F5.
- In the Visual Basic Editor, on the File menu, click Close and Return to Microsoft Excel when you finish writing the macro.
Top of Page
Copy part of a macro to create another macro
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
- To set the security level temporarily to enable all macros, do the following:
- On the Developer tab, in the Code group, click Macro Security.

- Under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
Note To help prevent potentially dangerous code from running, we recommend that you return to any one of the settings that disable all macros after you finish working with macros.
- Open the workbook that contains the macro that you want to copy.
- On the Developer tab, in the Code group, click Macros.
- In the Macro name box, click the name of the macro that you want to copy.
- Click Edit.
- In the code window of the Visual Basic Editor, select the lines of the macro that you want to copy.
Tip To copy the whole macro, include the Sub and End Sub lines in the selection.
- On the Edit menu, click Copy.
Tip You can also right-click and then click Copy, or you can press CTRL+C.
- In the Procedure box of the code window, click the module where you want to place the code.
- On the Edit menu, click Paste.
Tip You can also right-click and then click Paste, or you can press CTRL+V.
Tip You cannot edit your Personal Macro Workbook file (Personal.xlsb) because it is a hidden workbook that is always open. You must first unhide it by using the Unhide command. You can also open it in the Visual Basic Editor by pressing ALT+F11.
Top of Page
Assign a macro to an object, graphic, or control
- On a worksheet, right-click the object, graphic, or control to which you want to assign an existing macro, and then click Assign Macro.
- In the Macro name box, click the macro that you want to assign.
Top of Page
Delete a macro
- Do one of the following:
- Open the workbook that contains the macro that you want to delete.
- If the macro that you want to delete is stored in the personal macro workbook (Personal.xlsb), and this workbook is hidden, do the following to unhide the workbook:
- On the View tab, in the Window group, click Unhide.
- Under Unhide workbooks, click PERSONAL, and then click OK.
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
- On the Developer tab, in the Code group, click Macros.

- In the Macros in list, select the workbook that contains the macro that you want to delete. For example, click This Workbook.
- In the Macro name box, click the name of the macro that you want to delete.
- Click Delete.
Top of Page
See Also
Excel > Macros
Copy a macro module to another workbook
Excel 2007
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
Note The Ribbon is a component of the Microsoft Office Fluent user interface.
- To set the security level temporarily to enable all macros, do the following:
- On the Developer tab, in the Code group, click Macro Security.

- In the Macros Settings category, under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
Note To help prevent potentially dangerous code from running, we recommend that you return to any of the settings that disable all macros after you finish working with macros.
- Open the workbook that contains the module (module: A collection of declarations, statements, and procedures stored together as one named unit. There are two types of modules: standard modules and class modules.) that you want to copy and the workbook that you want to copy the module to.
- On the Developer tab, in the Code group, click Visual Basic.
- On the View menu, click Project Explorer
.
- Drag the module that you want to copy to the destination workbook.
Excel > Macros
Edit a macro
Excel 2007
Before you edit a macro (macro: An action or a set of actions that you can use to automate tasks. Macros are recorded in the Visual Basic for Applications programming language.), you should be familiar with the Visual Basic Editor (Visual Basic Editor: An environment in which you write new and edit existing Visual Basic for Applications code and procedures. The Visual Basic Editor contains a complete debugging toolset for finding syntax, run-time, and logic problems in your code.). The Visual Basic Editor can be used to write and edit a macro that is attached to a Microsoft Office Excel workbook.
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
Note The Ribbon is a component of the Microsoft Office Fluent user interface.
- To set the security level temporarily to enable all macros, do the following:
- On the Developer tab, in the Code group, click Macro Security.

- Under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
Note To help prevent potentially dangerous code from running, we recommend that you return to any of the settings that disable all macros after you finish working with macros.
- On the Developer tab, in the Code group, click Macros.
- In the Macro name box, click the macro that you want to edit.
- Click Edit.
Tip For Help with the Visual Basic Editor, on the Help menu, click Microsoft Visual Basic Help, or press F1.
See Also
Excel > Macros
Run a macro
Excel 2007

Tags button; code; commands; enable macros; macro; macro button; Quick Access Toolbar; Script; toolbars; vba

What are tags?
There are several ways to run a macro (macro: An action or a set of actions that you can use to automate tasks. Macros are recorded in the Visual Basic for Applications programming language.). You can always run a macro by using the menu command. Depending on how a macro is assigned to run, you might also be able to run it by pressing a CTRL combination shortcut key (shortcut key: A function key or key combination, such as F5 or CTRL+A, that you use to carry out a menu command. In contrast, an access key is a key combination, such as ALT+F, that moves the focus to a menu, command, or control.), or by clicking a toolbar button or an area on an object, graphic, or control. In addition, you can run a macro automatically when you open a workbook.
Note When you set the macro security level in Microsoft Office Excel to Disable all macros without notification, Excel will run only those macros that are digitally signed or stored in a trusted location, such as the Excel startup folder. If the macro that you want to run is not digitally signed or located in a trusted location, you can temporarily change the security level that enables all macros.
For more information about how to change macro security settings, see Change macro security settings in Excel.
What do you want to do?

Run a macro
Run a macro by pressing a CTRL combination shortcut key
Run a macro by clicking a button on the Quick Access Toolbar
Run a macro by clicking an area on a graphic object
Run a macro automatically upon opening a workbook

Run a macro
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
Note The Ribbon is a component of the Microsoft Office Fluent user interface.
- To set the security level temporarily to enable all macros, do the following:
- On the Developer tab, in the Code group, click Macro Security.

- In the Macro Settings category, under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
Note To help prevent potentially dangerous code from running, we recommend that you return to any one of the settings that disable all macros after you finish working with macros. or more information about how to change the settings, see Change macro security settings in Excel.
- Open the workbook that contains the macro.
- On the Developer tab, in the Code group, click Macros.
- In the Macro name box, click the macro that you want to run.
- Do one of the following:
- To run a macro in an Excel workbook, click Run.
Tip You can also press CTRL+F8 to run the macro. You can interrupt the execution of the macro by pressing ESC.
- To run a macro from a Microsoft Visual Basic module, click Edit, and then on the Run menu, click Run Sub/UserForm
, or press F5.
Top of Page
Run a macro by pressing a CTRL combination shortcut key
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
Note The Ribbon is a component of the Microsoft Office Fluent user interface.
- On the Developer tab, in the Code group, click Macros.

- In the Macro name box, click the macro that you want to assign to a CTRL combination shortcut key.
- Click Options.
- In the Shortcut key box, type any lowercase letter or uppercase letter that you want to use.
Note The shortcut key will override any equivalent default Excel shortcut key while the workbook that contains the macro is open. For a list of CTRL combination shortcut keys that are already assigned in Excel, see Excel shortcut and function keys.
- In the Description box, type a description of the macro.
- Click OK, and then click Cancel.
Top of Page
Run a macro by clicking a button on the Quick Access Toolbar
- Click the Microsoft Office Button
, and then click Excel Options.
- Click Customize, and then in the Choose commands from list, select Macros.
- In the list, click the macro that you created, and then click Add.
- To change the button image of the macro, select the macro in the box where it was added, and then click Modify.
- Under Symbol, click the button image that you want to use.
- To change the name of the macro that is displayed when you rest the pointer on the button, in the Display name box, type the name that you want to use.
- Click OK to add the macro button to the Quick Access Toolbar.

- On the Quick Access Toolbar, click the macro button.
Top of Page
Run a macro by clicking an area on a graphic object
- In the worksheet, select an existing graphic object, such as a picture, clip art, shape, or SmartArt.
- To create a hot spot on the existing object, on the Insert tab, in the Illustrations group, click Shapes, select the shape that you want to use, and then draw that shape on the existing object.

- Right-click the hot spot that you created, and then click Assign Macro on the shortcut menu (shortcut menu: A menu that shows a list of commands relevant to a particular item. To display a shortcut menu, right-click an item or press SHIFT+F10.).
- Do one of the following:
- To assign an existing macro to the graphic object, double-click the macro or enter its name in the Macro name box.
- To record a new macro to assign to the selected graphic object, click Record. When you finish recording the macro, click Stop Recording
on the Developer tab in the Code group.
Tip You can also click Stop Recording
on the left side of the status bar.
- To edit an existing macro, click the name of the macro in the Macro name box, and then click Edit.
- Click OK.
- In the worksheet, select the hot spot.
Tip This displays the Drawing Tools, adding a Format tab.

- On the Format tab, in the Shape Styles group, do the following:
- Click the arrow next to Shape Fill, and then click No Fill.
- Click the arrow next to Shape Outline, and then click No Outline.
Top of Page
Run a macro automatically upon opening a workbook
If you record a macro and save it with the name "Auto_Open," the macro will run whenever you open the workbook that contains the macro. Another way to automatically run a macro when you open a workbook is to write a Microsoft Visual Basic for Applications (VBA) procedure in the Open event of the workbook by using the Visual Basic Editor (Visual Basic Editor: An environment in which you write new and edit existing Visual Basic for Applications code and procedures. The Visual Basic Editor contains a complete debugging toolset for finding syntax, run-time, and logic problems in your code.). The Open event is a built-in workbook event that runs its macro code every time that that you open the workbook.
Create an Auto_Open macro
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Working with Excel and other Office applications, select the Developer tools check box, and then click OK.
- To set the security level temporarily to enable all macros, do the following:
- On the Developer tab, in the Code group, click Macro Security.

- In the Macro Settings category, under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
Note To help prevent potentially dangerous code from running, we recommend that you return to any one of the settings that disable all macros after you finish working with macros.
- If you want to save the macro with a particular workbook, open that workbook first.
- On the Developer tab, in the Code group, click Record Macro.
- In the Macro name box, type Auto_Open.
- In the Store macro in list, select the workbook where you want to store the macro.
Tip If you want a macro to be available whenever you use Excel, select Personal Macro Workbook. When you select Personal Macro Workbook, Excel creates a hidden personal macro workbook (Personal.xlsb), if it does not already exist, and saves the macro in this workbook. In Windows Vista, this workbook is saved in the C:\Users\user name\AppData\Local\Microsoft\Excel\XLStart folder. In Microsoft Windows XP, this workbook is saved in the C:\Documents and Settings\user name\Application Data\Microsoft\Excel\XLStart folder. Workbooks in the XLStart folder are opened automatically whenever Excel starts. If you want a macro in the personal macro workbook to be run automatically in another workbook, you must also save that workbook in the XLStart folder so that both workbooks are opened when Excel starts.
- Click OK, and then perform the actions that you want to record.
- On the Developer tab, in the Code group, click Stop Recording
.
Tip You can also click Stop Recording
on the left side of the status bar.
Notes
- If you chose to save the macro in This Workbook or New Workbook in step 6, save or move the workbook into one of the XLStart folders.
- Recording an Auto_Open macro has the following limitations:
- If the workbook where you save the Auto_Open macro already contains a VBA procedure in its Open event, the VBA procedure for the Open event will override all actions in the Auto_Open macro.
- An Auto_Open macro is ignored when a workbook is opened programmatically by using the Open method.
- An Auto_Open macro runs before any other workbooks open. Therefore, if you record actions that you want Excel to perform on the default Book1 workbook or on a workbook that is loaded from the XLStart folder, the Auto_Open macro will fail when you restart Excel, because the macro runs before the default and startup workbooks open.
If you encounter these limitations, instead of recording an Auto_Open macro, you must create a VBA procedure for the Open event as described in the next section of this article.
- If you want Excel to start without running an Auto_Open macro, hold down the SHIFT key when you start Excel.
Create a VBA procedure for the Open event of a workbook
The following example uses the Open event to run a macro when you open the workbook.
- If the Developer tab is not available, do the following to display it:
- Click the Microsoft Office Button
, and then click Excel Options.
- In the Popular category, under Working with Excel and other Office applications, select the Developer tools check box, and then click OK.
- To set the security level temporarily to enable all macros, do the following:
- On the Developer tab, in the Code group, click Macro Security.

- In the Macro Settings category, under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
Note To help prevent potentially dangerous code from running, we recommend that you return to any one of the settings that disable all macros after you finish working with macros.
- Save and close all open workbooks.
- Open the workbook where you want to add the macro, or create a new workbook.
- On the Developer tab, in the Code group, click Visual Basic.
- In the Project Explorer window, right-click the ThisWorkbook object, and then click View Code.
Tip In the Project Explorer window is not visible, on the View menu, click Project Explorer.
- In the Object list above the Code window, select Workbook.
This automatically creates an empty procedure for the Open event such as this:
Private Sub Workbook_Open()
End Sub
- Add the following lines of code to the procedure:
-
- Private Sub Workbook_Open()
- MsgBox Date
- Worksheets("Sheet1").Range("A1").Value = Date
- End Sub
- Switch to Excel and save the workbook as a macro-enabled workbook (.xlsm).
- Close and reopen the workbook. When you open the file again, Excel runs the Workbook_Open procedure, which displays today's date in a message box.
- Click OK in the message box.
Note that cell A1 on Sheet1 also contains the date as a result of running the Workbook_Open procedure.
Top of Page
Related Office Online discussions
Read related questions and answers from other Microsoft Office customers.

See Also
Excel > Macros
Workbook contains a user form or class module
The workbook that you are opening contains a user form or class module in the VBA project that is associated with the workbook. This may be a security risk because user forms and class modules may contain potentially unsafe macros.
If the macro security level is set to Disable all macros with notification or Disable all macros except digitally signed macros, you have the option to remove the VBA project from the workbook. You should choose to keep the VBA project only if you trust the source of this workbook. If you choose to remove the VBA project from your workbook, the VBA project is not merely disabled, it is actually deleted from the workbook.
If the macro security level is set to Disable all macros without notification, Microsoft Office Excel automatically removes the VBA project from the workbook. If you trust the source of this workbook, and you want to keep the VBA project, you can close the workbook without saving any changes. Then you must set your macro security level to Disable all macros with notification, so that you will be prompted to keep or remove the VBA project when you open the workbook again.
You should avoid setting the security level to Enable all macros (not recommended, potentially dangerous code can run).
To change the macro security settings in Excel, do the following:
- On the Developer tab, in the Code group, click Macro Security.

- In the Macro Settings category, under Macro Settings, click Enable all macros (not recommended, potentially dangerous code can run), and then click OK.
Note To help prevent potentially dangerous code from running, we recommend that you return to any of the settings that disable all macros after you finish working with macros.
Note You will see this alert only if the macro security level is set to any option that disables all macros. If the security level is Enable all macros (not recommended, potentially dangerous code can run), or the Trust access to the VBA project object model check box is selected, Excel retains the VBA project and loads it when the workbook is opened.
Excel > Security and privacy
Enable or disable macros in Office documents
Excel 2007

Tags disable macro; enable macros; macro; macro button; macro security; security;signature;vba

What are tags?
This article is about macro security and explains the risks involved in enabling macros and how the Trust Center in the 2007 Microsoft Office system can help to mitigate these risks. In this article, the term "document" can mean any Microsoft Office file that can contain macros. The term "macro" means a macro created by using Visual Basic for Applications (VBA) (Visual Basic for Applications (VBA): A macro-language version of Microsoft Visual Basic that is used to program Microsoft Windows-based applications and is included with several Microsoft programs.).
In this article

What is a macro and what is the security risk?
How can the Trust Center help protect me from unsafe macros?
What should I do when a security warning asks if I want to enable or disable a macro?
How do you change macro security settings for all documents in the Trust Center?

What is a macro and what is the security risk?
The purpose of a macro is to automate frequently used tasks. Although some macros are simply a recording of your keystrokes or mouse clicks, more powerful VBA (Visual Basic for Applications (VBA): A macro-language version of Microsoft Visual Basic that is used to program Microsoft Windows-based applications and is included with several Microsoft programs.) macros are written by developers who use code that can run many commands on your computer. For this reason, VBA macros pose a potential security risk. A hacker can introduce a malicious macro through a document that, if opened, allows the macro to run and potentially spread a virus (virus: A computer program or macro that "infects" computer files by inserting copies of itself into those files. When the infected file is loaded into memory, the virus can infect other files. Viruses often have harmful side effects.) on your computer.
Top of Page
How can the Trust Center help protect me from unsafe macros?
Before allowing a macro to be enabled in a document, the Trust Center checks for the following:
If the Trust Center detects a problem with any of these, the macro is disabled by default, and the Message Bar appears to notify you of a potentially unsafe macro.

If you click Options on the Message Bar, a security dialog box opens, giving you the option to enable the macro. See the next section for how to make a secure decision before you click an option.
Note In Microsoft Office Outlook 2007 and Microsoft Office Publisher 2007, security alerts appear in dialog boxes, not in the Message Bar.
Top of Page
What should I do when a security warning asks if I want to enable or disable a macro?
When a security dialog box appears, you have the option to enable the macro or leave it disabled. You should enable the macro only if you are sure it is from a trustworthy source.

Important If you are sure the document and macro are from a trustworthy source and have a valid signature, and you do not want to be notified about them again, instead of changing the default Trust Center settings to a less safe macro security setting, you can click Trust all documents from this publisher in the security dialog box. This adds the publisher to your Trusted Publishers list in the Trust Center. All software from that publisher is trusted. In the case where the macro doesn't have a valid signature, but you trust it and don't want to be notified again, instead of changing the default Trust Center settings to a less safe macro security setting, it is better to move the document to a trusted location. Documents in trusted locations are allowed to run without being checked by the Trust Center security system.
Depending on the situation, the security dialog box describes the specific problem. The following table lists the possible problems and offers advice on what you should or should not do in each case.
|
Problem
|
Advice
|
|
Macro is not signed Because the macro is not digitally signed, the identity of the macro publisher cannot be verified. Therefore, it is not possible to determine if the macro is safe or not.
|
Before you enable unsigned macros, make sure the macro is from a trustworthy source. You can still work in your document even though you don't enable the macro.
|
|
Macro signature is not trusted The macro is potentially unsafe, because the macro has been digitally signed, the signature is valid, and you have not chosen to trust the publisher who signed the macro.
|
You can explicitly trust (trust: Indicates whether you trust the individual or group to whom the certificate is issued. The default setting is Inherit Trust from Issuer, which means that the certificate is trusted because the issuer, usually a certificate authority, is trusted.) the macro publisher by clicking Trust all documents from this publisher in the security dialog box. This option appears only if the signature is valid. Clicking this option adds the publisher to your Trusted Publishers list in the Trust Center.
|
|
Macro signature is invalid The macro is potentially unsafe, because the macro has been digitally signed and the signature is invalid.
|
We recommend that you don't enable macros with invalid signatures. One possible reason the signature is invalid is that it has been tampered with. For more information, see How to tell if a digital signature is trustworthy.
|
|
Macro signature has expired The macro is potentially unsafe, because the macro has been digitally signed and the signature has expired.
|
Before enabling macros with expired signatures, make sure the macro is from a trustworthy source. If you have used this document in the past without any security issues, there is potentially less risk to enabling the macro.
|
Top of Page
How do you change macro security settings for all documents in the Trust Center?
Macro security settings are located in the Trust Center. However, if you work in an organization, your system administrator might have changed the default setting and prevented you from changing any settings.
Note When you change your macro settings in the Trust Center, they are changed only for the Office program that you are currently using. The macro settings are not changed for all your Office programs.
Which 2007 Microsoft Office system program are you using?

Access
Excel
Outlook
PowerPoint
Publisher
Visio
Word

Access
- Click the Microsoft Office Button
, and then click Access Options.
- Click Trust Center, click Trust Center Settings, and then click Macro Settings.
- Click the options that you want:
- Disable all macros without notification Click this option if you don't trust macros. All macros in documents and security alerts about macros are disabled. If there are documents with unsigned macros that you do trust, you can put those documents into a trusted location. Documents in trusted locations are allowed to run without being checked by the Trust Center security system.
- Disable all macros with notification This is the default setting. Click this option if you want macros to be disabled, but you want to get security alerts if there are macros present. This way, you can choose when to enable those macros on a case by case basis.
- Disable all macros except digitally signed macros This setting is the same as the Disable all macros with notification option, except that if the macro is digitally signed by a trusted publisher, the macro can run if you have already trusted the publisher. If you have not trusted the publisher, you are notified. That way, you can choose to enable those signed macros or trust the publisher. All unsigned macros are disabled without notification.
- Enable all macros (not recommended, potentially dangerous code can run) Click this option to allow all macros to run. This setting makes your computer vulnerable to potentially malicious code and is not recommended.
- Trust access to the VBA project object model This setting is for developers and is used to deliberately lock out or allow programmatic access to the VBA object model from any Automation client. In other words, it provides a security option for code that is written to automate an Office program and programmatically manipulate the Microsoft Visual Basic for Applications (VBA) environment and object model. This is a per user and per application setting, and denies access by default. This security option makes it more difficult for unauthorized programs to build "self-replicating" code that can harm end-user systems. For any Automation client to be able to access the VBA object model programmatically, the user running the code must explicitly grant access. To turn on access, select the check box.
Tip You can open the macro security settings dialog box from the Developer tab in the Ribbon, which is part of the Microsoft Office Fluent user interface. If the Developer tab is not available, click the Microsoft Office Button
, and then click Access Options. Click Popular, and then select the Show Developer tab in the Ribbon check box.
Top of Page
Excel
- Click the Microsoft Office Button
, and then click Excel Options.
- Click Trust Center, click Trust Center Settings, and then click Macro Settings.
- Click the options that you want:
- Disable all macros without notification Click this option if you don't trust macros. All macros in documents and security alerts about macros are disabled. If there are documents with unsigned macros that you do trust, you can put those documents into a trusted location. Documents in trusted locations are allowed to run without being checked by the Trust Center security system.
- Disable all macros with notification This is the default setting. Click this option if you want macros to be disabled, but you want to get security alerts if there are macros present. This way, you can choose when to enable those macros on a case by case basis.
- Disable all macros except digitally signed macros This setting is the same as the Disable all macros with notification option, except that if the macro is digitally signed by a trusted publisher, the macro can run if you have already trusted the publisher. If you have not trusted the publisher, you are notified. That way, you can choose to enable those signed macros or trust the publisher. All unsigned macros are disabled without notification.
- Enable all macros (not recommended, potentially dangerous code can run) Click this option to allow all macros to run. This setting makes your computer vulnerable to potentially malicious code and is not recommended.
- Trust access to the VBA project object model This setting is for developers and is used to deliberately lock out or allow programmatic access to the VBA object model from any Automation client. In other words, it provides a security option for code that is written to automate an Office program and programmatically manipulate the Microsoft Visual Basic for Applications (VBA) environment and object model. This is a per user and per application setting, and denies access by default. This security option makes it more difficult for unauthorized programs to build "self-replicating" code that can harm end-user systems. For any Automation client to be able to access the VBA object model programmatically, the user running the code must explicitly grant access. To turn on access, select the check box.
Tip You can open the macro security settings dialog box from the Developer tab in the Ribbon, which is part of the Microsoft Office Fluent user interface. If the Developer tab is not available, click the Microsoft Office Button
, and then click Excel Options. Click Popular, and then select the Show Developer tab in the Ribbon check box.
Top of Page
Outlook
- On the Tools menu, click Trust Center.
- Click Macro Settings.
- Click the options that you want:
- No warnings and disable all macros Click this option if you don't trust macros. All macros and security alerts about macros are disabled.
- Warnings for all macros This is the default setting. Click this option if you want macros to be disabled, but you want to get security alerts if there are macros present. This way, you can choose when to enable those macros on a case by case basis.
- Warnings for signed macros; all unsigned macros are disabled This setting is the same as the Disable all macros with notification option, except that if the macro is digitally signed by a trusted publisher, the macro can run if you have already trusted the publisher. If you have not trusted the publisher, you are notified. That way, you can choose to enable those signed macros or trust the publisher. All unsigned macros are disabled without notification.
- No security check for macros (Not recommended) Click this option to allow all macros to run. This setting makes your computer vulnerable to potentially malicious code and is not recommended.
Top of Page
PowerPoint
- Click the Microsoft Office Button
, and then click PowerPoint Options.
- Click Trust Center, click Trust Center Settings, and then click Macro Settings.
- Click the options that you want:
- Disable all macros without notification Click this option if you don't trust macros. All macros in documents and security alerts about macros are disabled. If there are documents with unsigned macros that you do trust, you can put those documents into a trusted location. Documents in trusted locations are allowed to run without being checked by the Trust Center security system.
- Disable all macros with notification This is the default setting. Click this option if you want macros to be disabled, but you want to get security alerts if there are macros present. This way, you can choose when to enable those macros on a case by case basis.
- Disable all macros except digitally signed macros This setting is the same as the Disable all macros with notification option, except that if the macro is digitally signed by a trusted publisher, the macro can run if you have already trusted the publisher. If you have not trusted the publisher, you are notified. That way, you can choose to enable those signed macros or trust the publisher. All unsigned macros are disabled without notification.
- Enable all macros (not recommended, potentially dangerous code can run) Click this option to allow all macros to run. This setting makes your computer vulnerable to potentially malicious code and is not recommended.
- Trust access to the VBA project object model This setting is for developers and is used to deliberately lock out or allow programmatic access to the VBA object model from any Automation client. In other words, it provides a security option for code that is written to automate an Office program and programmatically manipulate the Microsoft Visual Basic for Applications (VBA) environment and object model. This is a per user and per application setting, and denies access by default. This security option makes it more difficult for unauthorized programs to build "self-replicating" code that can harm end-user systems. For any Automation client to be able to access the VBA object model programmatically, the user running the code must explicitly grant access. To turn on access, select the check box.
Tip You can open the macro security settings dialog box from the Developer tab in the Ribbon, which is part of the Microsoft Office Fluent user interface. If the Developer tab is not available, click the Microsoft Office Button
, and then click PowerPoint Options. Click Popular, and then select the Show Developer tab in the Ribbon check box.
Top of Page
Publisher
- On the Tools menu, click Trust Center.
- Click Macro Settings.
- Click the options that you want:
- Disable all macros without notification Click this option if you don't trust macros. All macros in documents and security alerts about macros are disabled. If there are documents with unsigned macros that you do trust, you can put those documents into a trusted location. Documents in trusted locations are allowed to run without being checked by the Trust Center security system.
- Disable all macros with notification This is the default setting. Click this option if you want macros to be disabled, but you want to get security alerts if there are macros present. This way, you can choose when to enable those macros on a case by case basis.
- Disable all macros except digitally signed macros This setting is the same as the Disable all macros with notification option, except that if the macro is digitally signed by a trusted publisher, the macro can run if you have already trusted the publisher. If you have not trusted the publisher, you are notified. That way, you can choose to enable those signed macros or trust the publisher. All unsigned macros are disabled without notification.
- Enable all macros (not recommended, potentially dangerous code can run) Click this option to allow all macros to run. This setting makes your computer vulnerable to potentially malicious code and is not recommended.
- Trust access to the VBA project object model This setting is for developers and is used to deliberately lock out or allow programmatic access to the VBA object model from any Automation client. In other words, it provides a security option for code that is written to automate an Office program and programmatically manipulate the Microsoft Visual Basic for Applications (VBA) environment and object model. This is a per user and per application setting, and denies access by default. This security option makes it more difficult for unauthorized programs to build "self-replicating" code that can harm end-user systems. For any Automation client to be able to access the VBA object model programmatically, the user running the code must explicitly grant access. To turn on access, select the check box.
Top of Page
Visio
- On the Tools menu, click Trust Center.
- Click Macro Settings.
- Click the options that you want:
- Disable all macros without notification Click this option if you don't trust macros. All macros in documents and security alerts about macros are disabled. If there are documents with unsigned macros that you do trust, you can put those documents into a trusted location. Documents in trusted locations are allowed to run without being checked by the Trust Center security system.
- Disable all macros with notification This is the default setting. Click this option if you want macros to be disabled, but you want to get security alerts if there are macros present. This way, you can choose when to enable those macros on a case by case basis.
- Disable all macros except digitally signed macros This setting is the same as the Disable all macros with notification option, except that if the macro is digitally signed by a trusted publisher, the macro can run if you have already trusted the publisher. If you have not trusted the publisher, you are notified. That way, you can choose to enable those signed macros or trust the publisher. All unsigned macros are disabled without notification.
- Enable all macros (not recommended, potentially dangerous code can run) Click this option to allow all macros to run. This setting makes your computer vulnerable to potentially malicious code and is not recommended.
- Trust access to the VBA project object model This setting is for developers and is used to deliberately lock out or allow programmatic access to the VBA object model from any Automation client. In other words, it provides a security option for code that is written to automate an Office program and programmatically manipulate the Microsoft Visual Basic for Applications (VBA) environment and object model. This is a per user and per application setting, and denies access by default. This security option makes it more difficult for unauthorized programs to build "self-replicating" code that can harm end-user systems. For any Automation client to be able to access the VBA object model programmatically, the user running the code must explicitly grant access. To turn on access, select the check box.
Top of Page
Word
- Click the Microsoft Office Button
, and then click Word Options.
- Click Trust Center, click Trust Center Settings, and then click Macro Settings.
- Click the options that you want:
- Disable all macros without notification Click this option if you don't trust macros. All macros in documents and security alerts about macros are disabled. If there are documents with unsigned macros that you do trust, you can put those documents into a trusted location. Documents in trusted locations are allowed to run without being checked by the Trust Center security system.
- Disable all macros with notification This is the default setting. Click this option if you want macros to be disabled, but you want to get security alerts if there are macros present. This way, you can choose when to enable those macros on a case by case basis.
- Disable all macros except digitally signed macros This setting is the same as the Disable all macros with notification option, except that if the macro is digitally signed by a trusted publisher, the macro can run if you have already trusted the publisher. If you have not trusted the publisher, you are notified. That way, you can choose to enable those signed macros or trust the publisher. All unsigned macros are disabled without notification.
- Enable all macros (not recommended, potentially dangerous code can run) Click this option to allow all macros to run. This setting makes your computer vulnerable to potentially malicious code and is not recommended.
- Trust access to the VBA project object model This setting is for developers and is used to deliberately lock out or allow programmatic access to the VBA object model from any Automation client. In other words, it provides a security option for code that is written to automate an Office program and programmatically manipulate the Microsoft Visual Basic for Applications (VBA) environment and object model. This is a per user and per application setting, and denies access by default. This security option makes it more difficult for unauthorized programs to build "self-replicating" code that can harm end-user systems. For any Automation client to be able to access the VBA object model programmatically, the user running the code must explicitly grant access. To turn on access, select the check box.
Tip You can open the macro security settings dialog box from the Developer tab in the Ribbon, which is part of the Microsoft Office Fluent user interface. If the Developer tab is not available, click the Microsoft Office Button
, and then click Word Options. Click Popular, and then select the Show Developer tab in the Ribbon check box.
Top of Page