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 with others in a workbook, the script is attached to the workbook.

Important: Anyone with access to 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, click 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.

    Mouse over a script in the script gallery

    The Code Editor opens and displays the Details page for the script you clicked.

  2. Near the bottom of the Details page, set the Share with others in this workbook toggle to Yes.

    The Code Editor pane with the "Share with others in the workbook" control highlighted.

  3. To close the Code Editor, click the X at top right. Note that in the script gallery, the script you shared now has a Run symbol included in its icon, indicating it has been shared in the workbook and therefore can be run by anyone who can edit the workbook.

    Shared script icon in the scirpt gallery

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.

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. In the Code Editor, near the bottom of the Details page, set the Share with others in this workbook toggle to No.

You can also stop sharing a script in all workbooks if you own the script. However, there is no easy way to undo this action. If you later decide you didn't want to stop sharing the script, you will have to manually reshare it in each workbook.

  1. Click the script in the script gallery.

  2. In the Code Editor, at the bottom of the Details page, click Stop sharing in all workbooks.

    Link for stopping the sharing of a script in all workbooks

Set script permissions

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

After you have allowed a script to run, you have two options for changing a script’s permissions: stop allowing the script to run in the workbook while you are editing it, or stop sharing the script in the workbook. To stop allowing a script to run on your behalf, follow these steps:

  1. Click the script in the script gallery.

  2. In the Code Editor, at the bottom of the Details page, click Run Permission.

    Link for the Run Permission dialog

  3. In the Run Permission dialog, click Deny.

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

See Also

Introduction to Office Scripts in Excel

Office Scripts settings in M365

Expand your Office skills
Explore training
Get new features first
Join Office Insiders

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.

×