Save an Excel Workbook as an XLSM File in a SharePoint Document Library
Question details
Save a workbook containing VBA code and PivotTables as an Excel Macro-Enabled Workbook (.xlsm), then store the completed file in a SharePoint document library.

- Product
- Microsoft Excel and SharePoint document library
- Device & OS
- not provided
- Scenario
- The user has added VBA code and PivotTables to a workbook and needs to retain the macros when saving or uploading the file to SharePoint.
- Observed behavior
- The required outcome is a SharePoint-stored .xlsm file that preserves the workbook's VBA project and PivotTables.
Open the workbook in the Excel desktop app rather than Excel for the web, because browser editing cannot create or edit VBA code. Confirm that you have permission to upload files to the target SharePoint library and that the library accepts .xlsm files.
Save the workbook as an XLSM file directly to SharePoint from Excel
Use this method when the SharePoint library is available as a save location in the Excel desktop app.
The XLSM format preserves VBA macros, worksheets, and PivotTables. Do not save the macro workbook as .xlsx, because that format removes the VBA project.
In the SharePoint document library, select the workbook, then choose Open in Desktop App to open it in Microsoft Excel.
In Excel, select File > Save As, then select the SharePoint site or the document library location where you want to store the completed workbook.
In the Save as type list, choose Excel Macro-Enabled Workbook (*.xlsm). Enter a file name that ends in .xlsm if Excel does not add the extension automatically.
Select Save, then return to the SharePoint document library and confirm that the new .xlsm file appears. Open it in the desktop app to verify that the VBA code and PivotTables are present.

Save an XLSM copy locally and upload it to SharePoint
Use this method when Excel cannot save directly to the SharePoint library or when the library is not shown in Save As.
Save an XLSM Workbook and Upload It to SharePoint with WPS Office
WPS Office Spreadsheet can help you open a compatible macro-enabled workbook, save a copy in XLSM format, and upload the finished file to your SharePoint library through the browser. Review macro behavior in the desktop application before sharing the workbook with others.
- 1. Open the workbook in WPS Spreadsheet: Launch WPS Office, select Open, and choose the workbook you downloaded from SharePoint or saved locally.
- 2. Review workbook content: Check the worksheets and PivotTables in WPS Spreadsheet, and confirm that the required workbook data is ready before saving a new copy.
- 3. Save as an XLSM file: Select Menu > Save As, choose a local destination, select Excel Macro-Enabled Workbook (*.xlsm) if available, and select Save.
- 4. Upload the completed workbook: Open the SharePoint document library in your browser, select Upload > Files, and choose the saved .xlsm workbook.

Frequently Asked Questions
Why must I save a workbook with VBA code as XLSM instead of XLSX?
The XLSX format cannot retain a VBA project. In Excel desktop, use File > Save As and select Excel Macro-Enabled Workbook (*.xlsm) to preserve VBA code.
Can I create or edit VBA macros in Excel for the web?
No. Open the workbook through Open in Desktop App and use the Excel desktop application for VBA work, then save the file as .xlsm.
Will SharePoint allow me to upload an XLSM workbook?
Usually it can, but a site administrator may configure library policies that restrict macro-enabled files. If Upload > Files rejects the workbook, ask the library owner to review the file-type or security policy.
Do PivotTables remain available after saving as XLSM?
Yes. Saving as Excel Macro-Enabled Workbook (*.xlsm) preserves PivotTables as well as the workbook's VBA project, worksheets, and formulas.
Can users run macros from an XLSM file stored in SharePoint?
Users generally need to open the file in the Excel desktop app and may receive a macro security warning. They should enable macros only if they trust the workbook and its source.




