VBA & Macro Problems

Troubleshoot Office Scripts getUsedRange and addTable Failures in Excel Compatibility Mode

John WilsonJohn Wilson Nov 13, 2026 869 views

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.

Troubleshoot Office Scripts getUsedRange and addTable Failures in Excel 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.
Before you start

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.

Solution 1Recommended

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.

1
Open Save As in Excel

In Microsoft Excel, open the affected workbook, select File, and click Save As.

2
Choose Excel Workbook (*.xlsx)

In the Save as type drop-down list, choose Excel Workbook (*.xlsx). Do not leave the format as Excel 97-2003 Workbook (*.xls).

3
Save and reopen the new file

Click Save, close the original workbook, and open the newly saved .xlsx file. Confirm that Compatibility Mode no longer appears in the title bar.

4
Run the Office Script

Select the Automate tab, open the script that uses getUsedRange and addTable, and click Run. Verify that the script completes without error.

Save the workbook as .xlsx and re-run the Office Script
Compatibility mode removed: Saving as .xlsx is the first fix for Office Scripts failures in Excel 97-2003 compatibility mode. If the script still fails, continue with the next solution.
Free Microsoft Office alternative

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.

Opens and saves Excel 97-2003 .xls and modern .xlsx workbook files with high compatibilityFree, lightweight Office suite with a familiar ribbon-style spreadsheet interfaceSupports many Excel workflows, including VBA macros and add-in tools, without a subscriptionMaintains Microsoft Excel file format compatibility for .xlsx, .xls, and .csv filesSimplifies migration from Microsoft Excel with familiar menus and no learning curve
microsoft office alternative - wps office

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.