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
1
vote
0 answers

Office Script to copy data from one spreadsheet and add to a table

I'm trying to set up a Power Automate flow using office scripts to transfer data from multiple spreadsheets to one master table. The flow is triggered by a file being put in a folder, then it's supposed to run two scripts, one to get the data from…
CStevens
  • 13
  • 1
  • 5
1
vote
1 answer

connection to SQL database with Office script

is it possible to make a connection between Office 365 to SQL database using Office scripts? something simillar to ADODB.Connection in Excel VBA
Hamtash
  • 129
  • 9
1
vote
1 answer

Office Scripts- How to delete last row

I am trying to delete the last row in my Excel Online document using Office Scripts. I do not know what I am doing wrong, it is not deleting, does anyone have an idea? My code: function main(workbook: ExcelScript.Workbook) { let selectedSheet =…
Rosenz5
  • 59
  • 1
  • 6
1
vote
0 answers

Data not Refreshing on Excel Online

I have an Excel file on SharePoint with data from an external data source (SQL Server). I want to setup an Office script to automate the refresh of the data and then trigger it via power automate. However, i am unable to get the data refreshed (even…
Dee
  • 199
  • 4
  • 17
1
vote
1 answer

how to sortOn cell color on ExcelScript for web?

I am trying to sort in descending order the cells with a 'rose' background, as you can do in the 'filter' or 'custom sort' but with ExcelScript for web: range.getSort().apply([ { ascending: false, key: 5, sortOn:…
Wolfeius
  • 303
  • 2
  • 14
1
vote
2 answers

Iterate over a Range fast in Excelscript for web

I want to check that a range of cell are empty or has any values in them, I use this for loop : for (let i = 0; i <= namesRange.getCellCount(); i++) { if (namesRange.getCell(i,0).getText() == "") { break; } bookedCount +=…
Wolfeius
  • 303
  • 2
  • 14
1
vote
2 answers

Is there any way to have event handling with ExcelScript (Excel for web)

I am trying to create a "check in - check out" form to register the time in and out of workers at a company, using Excel for Web (ExcelScript). For every worker in the form, there has to be in the adjacent rows a Check IN and a Check OUT button…
Wolfeius
  • 303
  • 2
  • 14
1
vote
0 answers

How to search across a set of sheets in excel with office scripts?

Say I have a number of sheets in online excel, I want to search for a value across a specific set of them. So if I have 15 sheets, I only want to search sheets 3 to 11 for example. I know that I can do let sheet3 =…
1
vote
1 answer

TypeScript (Office Script) to force image compression in excel workbook

Coding gurus Is it possible to invoke something similar to this VBA code in excel online via Office Script? Sub test() Dim wsh As Worksheet Dim shp As Shape Set wsh = Worksheets("Sheet1") For Each shp In wsh.Shapes …
EPStudio
  • 47
  • 6
1
vote
2 answers

Excel online Office-Scripts . Copy Range A1:J10 from worksheet2 and paste it on last row of column A of another sheet

I need some help I can do it in Excel VBA but can't find out how in Excel Online. I have the below example 1 work but it is not dynamic I need it to paste under the last row. If you can help please provide an example or edit the code and resend.…
1
vote
1 answer

Pivot Table Filtering Office Scripts

I have an excel Pivot Table titled PivotTable1. Utilizing Office Scripts I am trying to automate the filtering. There are two columns prescriber and spent amount. I am trying to add a filter to the sum of the spent amount when it’s greater than…
Devkim514
  • 11
  • 1
1
vote
2 answers

Custom Date format values in array

I want to format dates in a Table column in Excel 365 Web using a custom format. I can format a cell but not the cell value picked up in a variable or array. function main(workbook: ExcelScript.Workbook) { let selectedSheet =…
sifar
  • 1,086
  • 1
  • 17
  • 43
1
vote
2 answers

Officescript how to set value in table cell (row/column) by row index

pretty simple question but I can't seem to find what I am looking for and wondering if it is possible this way, just starting using Officescript/typescript. In a part of my code, I get the index of the row with a value that matches (cRow is the…
nick
  • 789
  • 1
  • 11
  • 27
1
vote
1 answer

Run PowerShell Script from Office Scripts (Excel Online)

I am wondering if it is possible to run a PowerShell script from within an Office Script. My goal is to call the Office Script from PowerAutomate, then have the Office Script kick off a PowerShell process that performs some other automated tasks.…
1
vote
1 answer

CORS issue when calling API via Office Scripts Fetch

I am trying to make an API call via Office Scripts (fetch) to a publicly available Azure Function-based API I created. By policy we need to have CORS on for our Azure Functions. I've tried every domain I could think of, but I can't get the call to…
billoverton
  • 2,705
  • 2
  • 9
  • 32