Adding a Run Script Button to Excel in SharePoint: A Step-by-Step Guide

Hi.

I'm trying to add an Office script button to Excel in SharePoint.

I know I need to click the 'Add to workbook' button.

When the script file is on my local drive, I can add the button successfully.

However, when the script file is stored in SharePoint,

clicking 'Add to workbook' doesn't add the button and nothing happens. Can anyone help?

I appreciate your response.

Thanks.

Hey there I’ve got the solution for you.

To add an Office script button to Excel in SharePoint, you need to ensure the script file is properly referenced and configured. Here’s what you need to do:

  1. Upload the script file to SharePoint: Make sure the script file is uploaded to your SharePoint site. You can do this by going to the SharePoint site, clicking “Files” or “Documents” (depending on your site structure), and then clicking “Upload.”

  2. Get the URL of the script file: Once the script file is uploaded, right-click the file and select “Copy link” or “Get link” to get the URL of the script file.

  3. Format the URL correctly: The URL you copied needs to be modified to use the https://your-sharepoint-site.sharepoint.com/_api/web/GetFileByServerRelativeUrl('path-to-your-script-file')/$value format. Replace https://your-sharepoint-site.sharepoint.com with your actual SharePoint site URL and path-to-your-script-file with the actual path to your script file in SharePoint.

  4. Add the script to Excel: Open your Excel workbook and go to the “Home” tab in the ribbon. Click the “Add to workbook” button. In the “Add to workbook” dialog, paste the modified URL from step 3 and click “Add.”

  5. Verify the script: After adding the script, you should see the script button in your Excel workbook. Click the button to verify that it runs the script successfully.

If you’re still having issues, double-check that the script file is in the correct location, the URL is formatted correctly, and you have the necessary permissions to access the script file in SharePoint.

Hope this helps you out