Sharing Office Scripts in Excel for the Web

Office Scripts can be shared with other users of an Excel workbook. When you share a script in a workbook, you attach the script to the workbook, enabling other to view and run it.

Important: Anyone who can edit a workbook can view and run its attached scripts.

Note: This feature is only available to Microsoft 365 subscribers who have joined the Office Insider program. If you are a Microsoft 365 subscriber, make sure you have the latest version of Office.

Share your script in a workbook

You can use a script's Details page to share the script in a workbook. Your scripts are stored in your OneDrive, and when you share one, you create a link to it in the workbook you have open.

  1. On the Automate tab, in the script gallery, select the script you want to share. Note that you can only share your own scripts - any other scripts you see in the gallery are already shared in the workbook you have open.

    Office Script gallery

    The Code Editor opens and displays the script you selected.

  2. On the Code Editor menu, select Share.

    Office Script context menu

  3. Note the message about who can use the shared script, and select Share to proceed. In the script gallery, the script you shared now has a different icon, indicating it has been shared in the workbook and therefore can be run by anyone who can edit the workbook.

    Office Script gallery with a shared script

Notes: 

  • Shared scripts can be run by any user with write permissions to the workbook. Anything changed by the script is recorded as an edit by the person running the script, not the script’s owner.

  • Any updates you make to a shared script will automatically be shared with others. The script is updated when you save it. People using your script may need to reopen it if they have an old version open when you make a change.

  • An Office Script can only be shared within your organization. Scripts can't be shared to external users.  

Unshare a script

You can unshare any script in a workbook that you have open for editing. Note that if you unshare a script that you don't own, you cannot add it back - the owner of the script will have to do so if it is necessary.

  1. Click the script in the script gallery.

  2. On the Code Editor menu, select Stop sharing.

  3. In the Stop sharing in this workbook dialog, if you own the script, you can select Stop sharing in all workbooks - but be sure you want to, because this can't be undone. To reshare the script, you'll have to share it in each workbook again. When you are ready, select Stop Sharing.

    The Stop sharing in workbook dialog

Note: To share your script with a specific person instead of sharing it in the workbook, go to your OneDrive > Documents > Office Scripts folder, and share the script file.

Allow a shared script to run

The first time you run a script you don't own in a workbook, the Run Permission dialog box opens and asks whether to allow the script to view and edit the workbook. If you trust the author of the script, click Allow.

Run Permission dialog box for an Office script in Excel

See Also

Introduction to Office Scripts in Excel

Office Scripts settings in Microsoft 365

Need more help?

Expand your Office skills
Explore training
Got It
Get instant Excel help
Connect to an expert now
Subject to Got It terms and conditions

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×