r/OfficeJs • u/Individual_Pack_6352 • Apr 16 '21
Solved Need help with my (simple) Excel Office Script for Power Automate
Hi guys,
I'm a total noob regarding coding / Typescript and having some issues with my script which should pick cells from an Excel Table and pass it to Power Automate. The errors im getting are shown in the image.
function main(workbook: ExcelScript.Workbook): Testarray[] {// Get the first worksheet and the first table on that worksheet.let selectedSheet = workbook.getWorksheet("Versuchsauftrag");// Create the array of VA bjects to return.let Test: Testarray[] = [];var A0 = selectedSheet.getRange("D2"); // TestOrdervar A1 = selectedSheet.getRange("F9"); // COvar A2 = selectedSheet.getRange("F10"); // SAPNetworkvar A3 = selectedSheet.getRange("F11"); // SAPActivityvar A4 = selectedSheet.getRange("F15"); // Initiatorvar A5 = selectedSheet.getRange("G15"); // InitiatorTeamvar A6 = selectedSheet.getRange("C6"); // Projectvar A7 = selectedSheet.getRange("D3"); // Titlevar A8 = selectedSheet.getRange("A1"); // Versionvar A9 = selectedSheet.getRange("A1"); // Dummy var A0S = A0.getValue();var A1S = A1.getValue();var A2S = A2.getValue();var A3S = A3.getValue();var A4S = A4.getValue();var A5S = A5.getValue();var A6S = A6.getValue();var A7S = A7.getValue();var A8S = A8.getValue();var A9S = A9.getValue();Test = [A0S,A1S,A2S,A3S,A4S,A5S,A6S,A7S,A8S,A9S];// Log the array to verify we're getting the right rows.
console.log(Test);// Return the array of Valuess.return Test;}/**
* An array of VA Values will be returned from the script
* for the Power Automate flow.
*/interface Testarray {TestOrder: string;CO: string;SAPNetwork: string;SAPActivity: string;Initiator: string;InitiatorTeam: string;Project: string;Title: string;Version: string;Dummy : string;}
This is my code. Can anyone tell me what I'm doing wrong? I'm trying to use this as a reference: Beispielszenario für Office-Skripts: Automatisierte Aufgabenerinnerungen - Office Scripts | Microsoft Docs


2
u/Simon_IsReal Jan 09 '23 edited Jan 09 '23
At first look, i don't find any errors... I know it's passed a year, but I want try to help anyway 😂 I'm gonna try the code myself, read it with more attention and I'll see what I can do :)