Questions tagged [office-scripts]

Office Scripts is a feature that allows you to automate tasks in Microsoft Office using TypeScript. Currently, this feature is only supported in Excel. Use this tag to ask programming questions about Office Scripts, and consider adding the related tags Excel and TypeScript where relevant.

Office Scripts is a feature that allows you to automate tasks in Microsoft Office using TypeScript.

Currently, this feature is only supported in Excel.

Office Scripts can be created either by using a macro recorder, or by manually writing the script.

Office Scripts contrast themselves from VBA by being usable in Office Online, being primarily asynchronous (while VBA is nearly always synchronous), and lacking support for events. Office Scripts also cannot work with local files and programs.

The documentation is available here: https://learn.microsoft.com/en-us/office/dev/scripts/

Office Scripts use a subset of the Excel JavaScript API, the documentation for that can be found here: https://learn.microsoft.com/en-us/office/dev/add-ins/reference/overview/excel-add-ins-reference-overview

314 questions
8
votes
2 answers

Editing Office Scripts in Visual Studio Code

I would like to be able to edit my Office Scripts in Visual Studio Code. I know, that I can paste and copy my Scripts from VS to the Office Scripts Editor and vice-versa. But, I think, it would be more comfortable to be able to directly open, edit…
Mourad Louha
  • 113
  • 7
5
votes
1 answer

Cell Event Listener via Office scripts in MS Excel WebApp

In the Excel WebApp (Office 365) it is possible to place Office Scripts via the "Automate" tab, which is using the JavaScript-syntax and which could automate excel like a VBA-macro, but for the excel WebApp (Screenshot). How is it possible to create…
Peter
  • 323
  • 4
  • 15
4
votes
2 answers

Office Scripts VS Script Lab

I am confused about Office Scripts and Script Lab. Both can run javascript in Excel, but it seems the code can't be shared in them. For Office Scripts, some code like function main(workbook: ExcelScript.Workbook) { // Set fill color to FFC000 for…
Edward
  • 28,296
  • 11
  • 76
  • 121
4
votes
1 answer

Read data from another excel workbook using office script

Is it possible to read data from another closed excel workbook using excel office script? Thanks Suji
Suji
  • 87
  • 2
  • 8
4
votes
3 answers

How to delete all rows in a table using Office Scripts

I have a table on a spreadsheet and I want to delete all the existing data. I use the code below which works except when the table is already empty. // Get the row count let rowCount = table.getRangeBetweenHeaderAndTotal().getRowCount(); // Delete…
Paul Kelly
  • 975
  • 7
  • 13
4
votes
2 answers

How to call another script in Office scripts?

Is there anyway to call another script in office scripts? Have been attempting to call other functions into my main function in a single script and while it is indeed calling the function, for some reason the entriety of the function wont execute,…
Jai Hirani
  • 99
  • 9
4
votes
1 answer

Problem with names collection of worksheet object

I have encountered a problem with OfficeScript (I think). I wrote this script: async function main(context: Excel.RequestContext) { var RowCt = 0; var sheetName = ""; let workbook = context.workbook; let worksheets = workbook.worksheets; …
jkpieterse
  • 2,727
  • 1
  • 9
  • 18
4
votes
1 answer

Office Scripts error - the property is not available

I've created a script with the new Office Scripts in Excel on the web. The script simply sets the fill color for a range in the current worksheet, gets the used range, and then tries to write the range's address to the console. async function…
webdev2020
  • 43
  • 2
3
votes
2 answers

Is it possible to copy, paste, and delete data from one sheet to another in office scripts?

I have a document saved on SharePoint that documents testing. Once testing has been completed I would like to move the tests (entire row) to a separate sheet to archive the test schedule, in the next empty row going down, and because its now…
Ben
  • 33
  • 4
3
votes
2 answers

ExcelScript Type Definnitions

Really sorry if this has been answered somewhere… Does anyone know if a @types/ npm library exists for ExcelScript? Or even an ExcelScript.d.ts file somewhere?
Ben Koplin
  • 31
  • 1
3
votes
2 answers

Office Script that removes Row based on part of Text

I am making an Office Script that should delete a row based on part of the text in a cell in the first column. The trigger word should be "Applied" but it is often more text after the first word, i.e. "Applied formula" or "Applied number". The…
Rosenz5
  • 59
  • 1
  • 6
3
votes
1 answer

Failed to fetch error when using fetch API in office scripts

I am trying to run a post request from office scripts on an api, but kept getting a failed to fetch error each time when I add : "Content-type": "application/json" to the header, once I remove the content-type option or replace its value with…
Ferhi Malek
  • 484
  • 4
  • 15
3
votes
1 answer

How can I speed up my Office Scripts code so that it doesn't fail in Power Automate?

I have been asked to pull data from an Excel online spreadsheet on Sharepoint into Power BI to create a dashboard - no problem, right? Well, one of the 'data points' is actually fill colour of the cell indicating status. I did some googling and…
3
votes
1 answer

Why does my function return type turns into a promise once I read cell.value or put in console.log

I started coding a validation of my Excel Sheet. I implemented quite a bit so I try to keep the code short. My source code: function main(workbook: ExcelScript.Workbook) { console.log("starting..."); let cs =…
kism3t
  • 1,343
  • 1
  • 14
  • 33
3
votes
2 answers

Copy Excel OneDrive table to an specific cell on another Excel OneDrive table (Power Automate)

I need to copy data from one excel worksheet and paste (values only) on another worksheet using power automate + Office script I started to creat a flow using the answer in the link bellow. Power Automate: Copy Excel OneDrive table to the bottom of…
1
2 3
20 21