Читать книгу Excel 2019 Power Programming with VBA - Michael Alexander, Dick Kusleika - Страница 77

Other macro recording concepts

Оглавление

At this point, you should feel comfortable recording your own Excel macros. Next are some of the other important concepts you'll need to keep in mind when writing or recording macros.

By default, Excel workbooks are given the standard file extension .xlsx. Be aware that files with the .xlsx extension cannot contain macros. If your workbook contains macros and then you save that workbook as an .xlsx file, all VBA code is removed automatically. Luckily, Excel will warn you that your macro content will be removed when saving a workbook with macros as an .xlsx file.

If you want to retain the macros, you must save your file as an Excel Macro-Enabled Workbook. This gives your file an .xlsm extension. The idea is that all workbooks with an .xlsx file extension are automatically known to be safe, whereas you can recognize .xlsm files as a potential threat.

Alternatively, you can save your workbook as an Excel 97-2003 Workbook (with the .xls extension). The .xls file type can contain macros, but it doesn't support some of the modern features of Excel such as conditional formatting icons and pivot table slicers. You would typically use this file type only if there is a specific reason, such as that you need to have your workbook interact with an add-in that works only with .xls files.

Excel 2019 Power Programming with VBA

Подняться наверх