Excel 2010 Bible

(National Geographic (Little) Kids) #1

Part VI: Programming Excel with VBA


798


Note
If the Visual Basic (VB) Editor window is open when you open a workbook that contains macros, Excel does
not display the Security Warning above the Formula bar. Rather, it displays a dialog box with two buttons:
Enable Macros and Disable Macros. n


FIGURE 39.3

Excel displays a Security Warning if a workbook contains macros.


Rather than deal with individual workbooks, you may prefer to designate one or more folders as
“trusted locations.” All the workbooks in a trusted location are opened without a macro warning.
You designate trusted folders in the Trusted Locations section of the Trust Center dialog box.

Saving Workbooks That Contain Macros


If you store one or more VBA macros in a workbook, you must save the file with an XLSM
extension.

The first time you save a workbook that contains macros, the file format defaults to XLSX — and
this format can’t contain macros. Unless you change the file format to XLSM, Excel displays the
warning shown in Figure 39.4. You need to click No, and then choose Excel Macro-Enabled
Workbook (*.xlsm) from the Save As Type drop-down list in the Save As dialog box.

Note
Alternatively, you can save the workbook in the old Excel 97-2003 format (which uses an XLS extension). This
file format can contain macros. n


FIGURE 39.4

Excel warns you if your workbook contains macros and you attempt to save it in a nonmacro file format.

Free download pdf