Microsoft 365 and Office | Development | Office JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm trying to run this script and it worked the first time I ran it, but subsequent runs do not work. I get this error:
Line 13: Range delete: There was an internal error while processing the request.
Here is my script:
function main(workbook: ExcelScript.Workbook) {
let u7 = workbook.getWorksheet("U71");
let existingTable = u7.getTables()[0];
// Create a table with format on u7
let table1 = workbook.addTable(u7.getRange(), true);
table1.setPredefinedTableStyle("TableStyleLight13");
// Apply checked items filter on table column Plan Num
table1.getColumnByName(" Plan Num").getFilter().applyValuesFilter(["* 38303", "** 38303", "***", "Plan Num"]);
let visibleRows = table1.getRangeBetweenHeaderAndTotal().getVisibleView().getRows()
let firstVisibleRow = visibleRows[0].getRange().getRowIndex() + 1
let lastVisibleRow = visibleRows[visibleRows.length - 1].getRange().getRowIndex() + 1
u7.getRange(`${firstVisibleRow}:${lastVisibleRow}`).delete(ExcelScript.DeleteShiftDirection.up);
}
Thanks, Becki
An Office service that supports add-ins to interact with objects in Office client applications.
Building custom solutions that extend, automate, and integrate Microsoft 365 apps.