Skip to content

Commit 62a92dd

Browse files
[Shared runtime] Use associate instead of global (#389)
1 parent 9ed141b commit 62a92dd

File tree

3 files changed

+18
-28
lines changed

3 files changed

+18
-28
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,34 @@
22

33
Custom functions enable you to add new functions to Excel by defining those functions in JavaScript as part of an add-in. Users within Excel can access custom functions just as they would any native function in Excel, such as `SUM()`.
44

5-
This repository contains the source code used by the [Yo Office generator](https://github.com/OfficeDev/generator-office) when you create a new custom functions project. You can also use this repository as a sample to base your own custom functions project from if you choose not to use the generator. For more detailed information about custom functions in Excel, see the [Custom functions overview](https://docs.microsoft.com/office/dev/add-ins/excel/custom-functions-overview) article in the Office Add-ins documentation or see the [additional resources](#additional-resources) section of this repository.
5+
This repository contains the source code used by the [Yo Office generator](https://github.com/OfficeDev/generator-office) when you create a new custom functions project. You can also use this repository as a sample to base your own custom functions project from if you choose not to use the generator. For more detailed information about custom functions in Excel, see the [Custom functions overview](https://learn.microsoft.com/office/dev/add-ins/excel/custom-functions-overview) article in the Office Add-ins documentation or see the [additional resources](#additional-resources) section of this repository.
66

77
## Debugging custom functions
88

9-
This template supports debugging custom functions from [Visual Studio Code](https://code.visualstudio.com/). For more information see [Custom functions debugging](https://aka.ms/custom-functions-debug). For general information on debugging task panes and other Office Add-in parts, see [Test and debug Office Add-ins](https://docs.microsoft.com/office/dev/add-ins/testing/test-debug-office-add-ins).
9+
This template supports debugging custom functions from [Visual Studio Code](https://code.visualstudio.com/). For more information see [Custom functions debugging](https://aka.ms/custom-functions-debug). For general information on debugging task panes and other Office Add-in parts, see [Test and debug Office Add-ins](https://learn.microsoft.com/office/dev/add-ins/testing/test-debug-office-add-ins).
1010

1111
## Questions and comments
1212

1313
We'd love to get your feedback about this sample. You can send your feedback to us in the *Issues* section of this repository.
1414

15-
Questions about Office Add-ins development in general should be posted to [Microsoft Q&A](https://docs.microsoft.com/answers/questions/185087/questions-about-office-add-ins.html). If your question is about the Office JavaScript APIs, make sure it's tagged with [office-js-dev].
15+
Questions about Office Add-ins development in general should be posted to [Microsoft Q&A](https://learn.microsoft.com/answers/questions/185087/questions-about-office-add-ins.html). If your question is about the Office JavaScript APIs, make sure it's tagged with [office-js-dev].
1616

1717
## Join the Microsoft 365 Developer Program
18+
1819
Get a free sandbox, tools, and other resources you need to build solutions for the Microsoft 365 platform.
20+
1921
- [Free developer sandbox](https://developer.microsoft.com/microsoft-365/dev-program#Subscription) Get a free, renewable 90-day Microsoft 365 E5 developer subscription.
2022
- [Sample data packs](https://developer.microsoft.com/microsoft-365/dev-program#Sample) Automatically configure your sandbox by installing user data and content to help you build your solutions.
2123
- [Access to experts](https://developer.microsoft.com/microsoft-365/dev-program#Experts) Access community events to learn from Microsoft 365 experts.
2224
- [Personalized recommendations](https://developer.microsoft.com/microsoft-365/dev-program#Recommendations) Find developer resources quickly from your personalized dashboard.
2325

2426
## Additional resources
2527

26-
* [Custom functions overview](https://docs.microsoft.com/office/dev/add-ins/excel/custom-functions-overview)
27-
* [Custom functions best practices](https://docs.microsoft.com/office/dev/add-ins/excel/custom-functions-best-practices)
28-
* [Custom functions runtime](https://docs.microsoft.com/office/dev/add-ins/excel/custom-functions-runtime)
29-
* [Office Add-ins documentation](https://docs.microsoft.com/office/dev/add-ins/overview/office-add-ins)
30-
* More Office Add-ins samples at [OfficeDev on Github](https://github.com/officedev)
28+
- [Custom functions overview](https://learn.microsoft.com/office/dev/add-ins/excel/custom-functions-overview)
29+
- [Custom functions best practices](https://learn.microsoft.com/office/dev/add-ins/excel/custom-functions-best-practices)
30+
- [Custom functions runtime](https://learn.microsoft.com/office/dev/add-ins/excel/custom-functions-runtime)
31+
- [Office Add-ins documentation](https://learn.microsoft.com/office/dev/add-ins/overview/office-add-ins)
32+
- More Office Add-ins samples at [OfficeDev on Github](https://github.com/officedev)
3133

3234
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
3335

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/commands.ts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* See LICENSE in the project root for license information.
44
*/
55

6-
/* global global, Office, self, window */
6+
/* global Office */
77

88
Office.onReady(() => {
9-
// If needed, Office.js is ready to be called
9+
// If needed, Office.js is ready to be called.
1010
});
1111

1212
/**
@@ -21,24 +21,12 @@ function action(event: Office.AddinCommands.Event) {
2121
persistent: true,
2222
};
2323

24-
// Show a notification message
24+
// Show a notification message.
2525
Office.context.mailbox.item.notificationMessages.replaceAsync("action", message);
2626

27-
// Be sure to indicate when the add-in command function is complete
27+
// Be sure to indicate when the add-in command function is complete.
2828
event.completed();
2929
}
3030

31-
function getGlobal() {
32-
return typeof self !== "undefined"
33-
? self
34-
: typeof window !== "undefined"
35-
? window
36-
: typeof global !== "undefined"
37-
? global
38-
: undefined;
39-
}
40-
41-
const g = getGlobal() as any;
42-
43-
// The add-in command functions need to be available in global scope
44-
g.action = action;
31+
// Register the function with Office.
32+
Office.actions.associate("action", action);

0 commit comments

Comments
 (0)