Lesson 10 of 60 – Saving Macro-Enabled Excel Files
17%

Saving Macro-Enabled Excel Files

When you create or record a Macro in Excel, the workbook must be saved in a format that can store VBA Macro code. A normal Excel workbook usually uses the .xlsx extension, while a macro-enabled workbook commonly uses the .xlsm extension.

Note: If a workbook contains VBA Macros, save it in a macro-enabled format such as Excel Macro-Enabled Workbook (*.xlsm) so that the Macro code can be preserved.

1. What is a Macro-Enabled Workbook?

A Macro-Enabled Workbook is an Excel workbook that can store VBA Macro code.

It is commonly saved using the .xlsm file extension.

This format is useful when you create Excel workbooks containing Macros or VBA programs.

2. What is the .xlsm Extension?

The .xlsm extension identifies an Excel Macro-Enabled Workbook.

For example:

Student_Result.xlsm

This type of workbook can store VBA Macro code along with worksheet data and formatting.

3. What is the .xlsx Extension?

The .xlsx format is a standard Excel workbook format.

It is commonly used for workbooks that do not need to store VBA Macro code.

For a workbook containing VBA Macros, you should use an appropriate Macro-enabled format.

4. .xlsx vs .xlsm

Extension Workbook Type Macro Support
.xlsx Excel Workbook Does not store VBA Macro code.
.xlsm Excel Macro-Enabled Workbook Can store VBA Macro code.

5. Why Save a Macro-Enabled File?

A Macro-enabled format is required when you want to keep VBA Macro code inside the workbook.

If you save a Macro workbook in an inappropriate format, Excel can warn you that Macro functionality cannot be preserved.

6. Open the Save As Window

To save a workbook in a Macro-enabled format, use the Save As command.

You can use:

File → Save As

This allows you to choose the file name, location, and file type.

7. Choose the File Location

In the Save As window, choose the folder where you want to store the workbook.

For example, you can save your practice workbook in a folder named Excel Macro Practice.

8. Enter the File Name

Enter a meaningful name for your workbook.

For example:

Student_Marksheet

Excel will add the selected file extension when the workbook is saved.

9. Select File Type

In the Save As window, locate the Save as type option.

Click the drop-down list to see the available Excel file formats.

10. Select Excel Macro-Enabled Workbook

From the file type list, select:

Excel Macro-Enabled Workbook (*.xlsm)

This tells Excel that the workbook should be saved in a format that supports VBA Macro code.

11. Click Save

After selecting the Macro-enabled workbook format, click Save.

Excel will save the workbook using the selected file type.

12. Format Warning Message

When saving a workbook that contains features not supported by the selected format, Excel may display a warning message.

If you selected the Macro-enabled workbook format correctly, the workbook can store VBA Macro code.

13. Macro Code is Preserved

Saving the workbook as .xlsm allows VBA Macro code to remain part of the workbook.

When you reopen the workbook, the Macro can be available according to the workbook and Excel security settings.

14. Reopening a Macro-Enabled Workbook

After saving a workbook as .xlsm, you can close it and open it again later.

The workbook can contain its worksheets, formatting, formulas, and VBA Macro code.

15. Macro Security When Opening

When a Macro-enabled workbook is opened, Excel's Macro Security settings determine how its VBA Macros are handled.

A security notification may appear when Macros are blocked.

Only enable Macros when you trust the workbook and understand its source.

16. Example File Names

Examples of Macro-enabled workbook names include:

  • Student_Result.xlsm
  • Attendance_System.xlsm
  • Fee_Report.xlsm
  • Sales_Report.xlsm
  • Employee_Data.xlsm

17. Saving Your First Macro

Suppose you have recorded a Macro named:

FormatStudentData

To preserve the Macro, save the workbook as:

Student_Marksheet.xlsm

The workbook can then store the recorded Macro along with the worksheet data.

18. What Happens if You Choose .xlsx?

If a workbook contains VBA Macro code and you try to save it as a format that cannot preserve the Macro, Excel can display a warning.

The Macro code may not be retained if you continue with a format that does not support VBA Macros.

Therefore, choose .xlsm when you need to preserve VBA Macro code.

19. Save vs Save As

Save saves changes to the current workbook using its existing file format.

Save As allows you to create a saved version using a different file name, location, or file type.

When converting a workbook to a Macro-enabled format, Save As is commonly used to select the required file type.

20. Macro-Enabled Workbook for Practice

While learning Excel VBA, it is useful to create a separate folder for Macro practice files.

For example:

Excel Macro Practice
    ├── Student_Marksheet.xlsm
    ├── Attendance_System.xlsm
    └── Report_Generator.xlsm

21. Saving Multiple Macro Projects

Different Excel VBA projects can be saved as separate Macro-enabled workbooks.

For example, a student result project and an attendance project can each have their own .xlsm workbook.

22. Check the File Extension

After saving the workbook, check the file name to confirm that it uses the .xlsm extension when Macro support is required.

For example:

My_First_Macro.xlsm

23. Save Before Testing

It is a good practice to save your workbook before testing important Macro changes.

This helps ensure that your latest Macro code and workbook changes are stored.

24. Save After Editing VBA

When you edit VBA code in the Visual Basic Editor, save the workbook after making the required changes.

The Macro-enabled workbook format allows the VBA project to be stored with the workbook.

25. Simple Steps to Save a Macro

  1. Open your Macro workbook.
  2. Click File.
  3. Select Save As.
  4. Choose the required location.
  5. Enter the workbook name.
  6. Select Excel Macro-Enabled Workbook (*.xlsm).
  7. Click Save.

26. Common Mistake

A common beginner mistake is saving a workbook containing VBA code in a file format that does not support VBA Macros.

Always check the file type when saving a workbook that contains Macro code.

27. Practical Example

Suppose you recorded a Macro called:

FormatStudentData

Use the following process:

  1. Click File.
  2. Click Save As.
  3. Enter Student_Marksheet as the file name.
  4. Select Excel Macro-Enabled Workbook (*.xlsm).
  5. Click Save.

The resulting file can be:

Student_Marksheet.xlsm

28. Important File Formats

Format Extension Purpose
Excel Workbook .xlsx Standard Excel workbook without VBA Macro storage.
Excel Macro-Enabled Workbook .xlsm Stores Excel workbook data and VBA Macro code.

29. Complete Saving Workflow

The complete workflow for saving a Macro-enabled workbook is:

  1. Create or record a Macro.
  2. Complete the required Excel work.
  3. Open File → Save As.
  4. Choose a file location.
  5. Enter a meaningful file name.
  6. Select Excel Macro-Enabled Workbook (*.xlsm).
  7. Click Save.
  8. Confirm the file extension.
  9. Reopen the file later when required.

30. Complete Understanding of Macro-Enabled Files

A Macro-enabled workbook is used when an Excel workbook needs to store VBA Macro code. The common extension for this format is .xlsm.

To save a Macro-enabled workbook, use File → Save As and select Excel Macro-Enabled Workbook (*.xlsm).

Using the correct file format helps preserve the VBA Macro code inside the workbook so that it can be used again when the workbook is reopened.

📌 Key Points

  • Macro-enabled workbooks commonly use the .xlsm extension.
  • The .xlsm format can store VBA Macro code.
  • The .xlsx format does not store VBA Macro code.
  • Use File → Save As to choose a different workbook format.
  • Select Excel Macro-Enabled Workbook (*.xlsm).
  • Check the file extension after saving.
  • Save the workbook after making important VBA changes.
  • Be careful when opening Macro-enabled files from unknown sources.

🧠 Quick Quiz

Question: Which file format should normally be used to preserve VBA Macro code in an Excel workbook?