
Power Automate와 함께 사용하기 위해 Excel Online의 새로운 스크립팅 기능(VBA 아님)을 사용하고 있습니다. 특정 지점 이후의 행을 삭제하는 스크립트를 만들려고 합니다. 처음에는 작동했지만 계속해서 오류가 발생했습니다.
나는 다음의 기능을 사용했습니다.
내 최종 스크립트는 다음과 같습니다
function main(workbook: ExcelScript.Workbook) {
// [Directly from link 1]
// Get the current worksheet.
let selectedSheet = workbook.getActiveWorksheet();
// [Directly from link 3]
// Get the first table on the current worksheet.
const currentSheet = workbook.getActiveWorksheet();
const table = currentSheet.getTables()[0];
// [Directly from link 1]
// Get the last used cell at the end of the column.
// This recreates the Ctrl+Down arrow key behavior.
let firstCell = selectedSheet.getRange("A1");
let firstColumn = selectedSheet.getRange("A1").getRangeEdge(ExcelScript.KeyboardDirection.down);
let cellAfter = firstColumn.getOffsetRange(1, 0);
// [My own creation using link 2]
// Saves the row number of the cell after the Ctrl+Down
let FinalRow = cellAfter.getRowIndex();
// [My own creation using link 4]
// Deletes all rows from the last row for 2000 rows.
// Without '-1' a blank row is left. '-1' deletes all the empty rows.
table.deleteRowsAt(FinalRow - 1,2000);
}
처음 스크립트를 실행했을 때 어떤 문제도 발생하지 않았으며 작동합니다. 두 번째로 스크립트를 실행했을 때 제대로 작동했지만 "라인 25: 테이블 deleteRowsAt: 인수가 유효하지 않거나 누락되었거나 형식이 잘못되었습니다."라는 오류가 표시되었습니다. 새로 고친 후 스크립트가 "ExcelScript"에서 오류를 표시하는 세 번째 문제에 부딪혔지만 작동하고 "Line 25..." 오류를 표시하는 것으로 생각됩니다. 아래 스크린샷.
""ExcelScript" 및 "Line 25..." 오류를 표시하는 스크립트"
오류 없이 작동하려면 이 기능이 필요합니다. Power Automate 흐름에 추가하면 오류로 인해 중단되기 때문입니다.
'작업' 스크립트에서 오류가 발생하더라도 계속 진행되도록 Power Automate에서 '다음 이후 실행'을 구성할 수 있다는 것을 알고 있습니다. 그러나 Power Automate를 통해 스크립트를 실행하면 Excel Online을 통해 실행하면 '작동'하지만 '작동'하지 않습니다.
귀하의 도움에 감사드립니다.