Troubleshoot Office Scripts getUsedRange and addTable Failures in Excel Compatibility Mode
Question details
The user needs to resolve an Office Script failure where getUsedRange and addTable do not run correctly when the workbook is open in Excel 97-2003 compatibility mode.

- Product
- Microsoft Excel Office Scripts
- Device & OS
- not provided
- Scenario
- Running or editing an Office Script that reads the used range and adds a table while the workbook is open in Excel 97-2003 compatibility mode.
- Observed behavior
- The script fails or errors while the workbook is in compatibility mode; after the file is saved as .xlsx and verified as editable with a valid used range, the script is expected to run successfully.
Open the affected workbook in Microsoft Excel, select File > Info, and confirm that the workbook is not protected and is editable. Save a copy of the file before converting it from Excel 97-2003 compatibility mode to the .xlsx format.
Save the workbook as .xlsx and re-run the Office Script
Use this first when the workbook opens in Excel 97-2003 compatibility mode and the script fails on getUsedRange or addTable.
Office Scripts depend on modern workbook APIs that can be blocked or unreliable in legacy .xls compatibility mode. Saving the file to the modern .xlsx format removes the compatibility restriction and preserves the workbook data for testing.
In Microsoft Excel, open the affected workbook, select File, and click Save As.
In the Save as type drop-down list, choose Excel Workbook (*.xlsx). Do not leave the format as Excel 97-2003 Workbook (*.xls).
Click Save, close the original workbook, and open the newly saved .xlsx file. Confirm that Compatibility Mode no longer appears in the title bar.
Select the Automate tab, open the script that uses getUsedRange and addTable, and click Run. Verify that the script completes without error.

Check protection, used range, and workbook integrity
Use this if the script still fails after saving as .xlsx or if the workbook contains protection, invalid used ranges, or corrupted objects.
Use WPS Office Spreadsheets as a Free Microsoft Excel Alternative for Workbook Files
Because Office Scripts are a Microsoft Excel automation feature and the compatibility-mode failure comes from Microsoft Office’s legacy file handling, WPS Office does not fix the Office Scripts engine itself. WPS Office is a free, lightweight, easy-to-use alternative that opens, edits, and saves Excel-compatible .xls and .xlsx workbooks with a familiar ribbon interface and smooth migration from Excel.

Frequently Asked Questions
Why does saving a workbook as .xlsx fix Office Scripts errors?
Office Scripts use modern workbook APIs, and Excel 97-2003 compatibility mode may restrict or break those APIs. Saving the file as Excel Workbook (*.xlsx) removes Compatibility Mode and gives the script the expected modern file structure.
Can WPS Office run Microsoft Office Scripts?
No. Office Scripts are a Microsoft Excel automation feature. WPS Office can open, edit, and save .xls and .xlsx workbook files, but it does not run Office Scripts.
How do I check whether my workbook is protected in Excel?
Open File > Info, choose Protect Workbook, and check whether any protection is enabled. Also go to the Review tab and look for Unprotect Sheet or Unprotect Workbook options.
What should I do if the script still fails after converting to .xlsx?
Press Ctrl+End on each worksheet to verify the used range, clear unused rows and columns, open Formulas > Name Manager to check for broken names, and test the script in a sanitized sample workbook. If it still fails, provide the Office Scripts session ID and sample workbook to Microsoft support.




