0

We have been moving towards writing office scripts instead of VBA macros. I am also aware of the Microsoft Graph REST APIs for excel. Can someone guide me how can I execute an office script (like a sample one below) programmatically without creating an excel instance locally?


async function main(context: Excel.RequestContext) {
  // Set range A1 on selectedSheet
  let workbook = context.workbook;
  let worksheets = workbook.worksheets;
  let selectedSheet = worksheets.getActiveWorksheet();
  selectedSheet.getRange("A1").values = [
    ["Hello World"]
  ];
}

I could not find any graph api to do so.

Thanks.

1
  • 1
    Yes, that could be done by either taking the user credentials before hand and generate the access token using the OAuth2 api's but I am also sure that the excel graph api's would in future support application permissions like other resources do. The problem is there is no API to run an office script. Are you saying there would be in near future to do so @RaymondLu? Commented Jun 8, 2020 at 13:51

2 Answers 2

2

To run office script via Graph API, there would be two requirements: 1. Office JS library: parse the office script to build the request and also parse the result in response. 2. Specific Graph API: run the request in service side against the target file.

Unfortunately, none of them is availabe now.

However, there is another ongoing work to integrate Office Scripts with PowerAutomate, which will enable us to run the scripts against a workbook on PowerAutomate (without a local Excel instance). Here (https://mybuild.microsoft.com/sessions/bc1bc3e6-9dc1-474e-a5d6-409af2fa0ad3?source=sessions) is the video to introduce Office Scripts (and also its integration with PowerAutomate) in recent Microsoft Build. This feature would be in public preview soon.

Sign up to request clarification or add additional context in comments.

3 Comments

There is an ongoing work to integrate Office Scripts with PowerAutomate, which will enable us to run the scripts against a workbook on PowerAutomate (without a local Excel instance). Here (mybuild.microsoft.com/sessions/…) is the video to introduce Office Scripts (and also its integration with PowerAutomate) in recent Microsoft Build. This feature would be in public preview soon.
That's great @Joe Zhao. If you could convert your notes from the comment to the post, I could accept it as an answer.
I merged the comments to my previous answer.
2

Microsoft has announced the Office Scripts integration with Microsoft Power Automate (preview), where you can run your Office Scripts with schedule-based triggers or event-based triggers.

Here are a few links that might be helpful:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.