Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

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

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

Share and unshare 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. When you share one, you create a link to it in the workbook you have open.

How to share a script from the Details page depends on your version of Excel. Sharing through Script access in the Details page is currently rolling out and may not be available to all users. Sharing through the Code Editor's More options (...) menu is available if sharing through Script access isn't available.

Share and unshare through Script access

Office Scripts sharing through Script access is currently rolling out and may not be available to all users. To share with Script access, take the following steps. 

  1. On the Automate tab, select the script you want to share from the gallery or the All Scripts list.

    Note: You can only share your own scripts. You might have access to other scripts that have been shared with you or built-in sample scripts that can’t be shared.


    Office Script gallery

    The Code Editor opens and displays the script you selected.

  2. Scroll to the Script access section and open it if the section is not already open. If sharing through Script access is available to you, you'll see a button that says Add in workbook.

    Share Office Scripts through Script access, using the Add in workbook button.

  3. Select the Add in workbook button to add the script to your workbook with a button.

    Note: 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.

  4. Select the down arrow to open a menu with the additional options Add without button and Remove from workbook

    Use the Add in workbook dropdown menu to adjust sharing options.

  5. Select Add without button to add the script to your workbook without adding a button to the workbook. To view scripts added to a workbook without a button, see the Code Editor > This workbook list.

  6. Select Remove from workbook to remove the script from your workbook.

    Note: Deleting a script button from the workbook won't remove that script from the Code Editor > This workbook list. Use Remove from workbook to remove a script from the workbook.

    Important: Be sure you want to stop sharing, because this can't be undone. To reshare the script, you'll have to manually share it in each workbook again. When you are ready, select Stop Sharing.

Share through the Code Editor's More options menu

If sharing through Script access isn't available, use the Code Editor's More options (...) menu.

  1. On the Automate tab, select the script you want to share from the gallery or the All Scripts list.

    Note: You can only share your own scripts. You might have access to other scripts that have been shared with you or built-in sample scripts that can’t be shared.

    Office Script gallery

    The Code Editor opens and displays the script you selected.

  2. On the Code Editor's More options (...) menu, select Share.

  3. Read 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. This indicates it has been shared in the workbook and 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.  

  • You can also share a script by creating a button. For more information, see Create a button to run an Office Script.

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 can't add it back. The owner of the script will have to do it themselves.

  1. Select the script in the script gallery.

  2. On the Code Editor's More options (...) 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. 

    Important: Be sure you want to stop sharing, because this can't be undone. To reshare the script, you'll have to manually 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.

Save Office Scripts on a SharePoint site 

Save Office Scripts on SharePoint to share them with your team. When you save a script to SharePoint, anyone with access to the SharePoint can view, edit, or run the script.

Move a script to SharePoint

Follow these steps to change where a script is stored.

  1. On the Automate tab, select the script you want to share from the gallery or the All Scripts list. The Code Editor opens and displays the script you selected. 

  2. Select Edit

  3. Click on the script name to open the script renaming callout. 

  4. Click on the Move button. This opens a file picker where you can select folders in your SharePoint site. Saving to a new location moves the script to that location. 

Notes: 

  • Moving a script can take up to a minute.

  • Moving a script breaks the share links and flows currently associated with it. If there are any links that could be associated with the script, a warning message appears. The warning message doesn't always mean breakage will occur, only that one is possible. 

MoveScripttoSharePoint

Allow a shared script to run

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

Run Permission dialog box for an Office script in Excel

Note: The first time you run a script, the Run Permission dialog also opens whenever the script is updated by another colleague in your organization.

See Also

Introduction to Office Scripts in Excel

Office Scripts settings in Microsoft 365

Create a button to run an Office Script

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?

Thank you for your feedback!

×