Microsoft Office Tutorials and References
In Depth Information
Another handy feature of Excel macros is that you can create macros that run when a
workbook is opened. For example, you might want to ensure that no cells in a worksheet
are highlighted when the worksheet opens. You can create a macro that removes any
special formatting from your worksheet cells when its workbook opens, enabling you to
emphasize the data you want as you present the information to your colleagues.
In this chapter, you’ll learn how to open, run, create, and modify macros; create Quick
Access Toolbar buttons and shapes that enable you to run macros with a single mouse
click; define macro security settings; and run a macro when a workbook is opened.
Practice Files Before you can complete the exercises in this chapter, you need to copy
the book’s practice files to your computer. The practice files you’ll use to complete the
exercises in this chapter are in the Chapter12 practice file folder. A complete list of
practice files is provided in “Using the Practice Files” at the beginning of this topic.
Enabling and Examining Macros
It’s possible for unscrupulous programmers to write viruses and other harmful programs
by using the Microsoft Visual Basic for Applications (VBA) programming language, so
you need to be sure that you don’t run macros from unknown sources. In addition to
running protective software such as Windows Defender, you can also change your Excel
macro security settings to control when macros can be run. After you’re sure a macro is
safe, you open it in the Visual Basic Editor to examine its code.
Macro Security in Excel 2010
In versions of Excel prior to Excel 2007, you could define macro security levels to determine
which macros, if any, your workbooks would be allowed to run, but there was no
workbook type in which all macros were disallowed. Excel 2010 has several file types you can
use to control whether a workbook will allow macros to be run. The following table
summarizes the macro-related file types.
Regular Excel 2010 workbook; macros are disabled
Regular Excel 2010 workbook; macros are enabled
Excel 2010 template workbook; macros are disabled
Excel 2010 template workbook; macros are enabled