Excel 2019 Bible

(singke) #1

Part VI: Automating Excel


Excel remembers your decision; if you enable the macros, you won’t see the security warn-
ing the next time you open that file.

FIGURE 42.3
Excel displays a security warning if a workbook contains macros.

If the Visual Basic Editor (VBE) window is open when you open a workbook that contains macros, Excel does not
display the security warning above the Formula bar. Instead, it displays a dialog box with two buttons: Enable Macros
and Disable Macros.

Rather than deal with individual workbooks, you may prefer to designate one or more fold-
ers as “trusted locations.” All of 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 (or even an empty VBA module),
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 42.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.
Free download pdf