-
Notifications
You must be signed in to change notification settings - Fork 62
/
office.beforedocumentclosenotification.yml
112 lines (96 loc) · 4.4 KB
/
office.beforedocumentclosenotification.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
### YamlMime:TSType
name: Office.BeforeDocumentCloseNotification
uid: 'office!Office.BeforeDocumentCloseNotification:interface'
package: office!
fullName: Office.BeforeDocumentCloseNotification
summary: >-
Represents a modal notification dialog that can appear when the user attempts to close a document. The document won't
close until the user responds. The notification dialog will allow the user to confirm the request to close the
document or cancel the request to close the document. This API is only supported in Excel.
remarks: >-
**Requirement set**: [SharedRuntime
1.2](https://learn.microsoft.com/javascript/api/requirement-sets/common/shared-runtime-requirement-sets)
#### Examples
```TypeScript
// Enable the before document close modal notification dialog.
async function enableNotification() {
await Office.addin.beforeDocumentCloseNotification.enable();
}
// Add an event handler to detect when the document close operation is cancelled.
Office.addin.beforeDocumentCloseNotification.onCloseActionCancelled(async function () {
// When the document close attempt is cancelled, write a message to the active range in the worksheet.
await Excel.run(async (context) => {
const range = context.workbook.getSelectedRange();
range.values = [["Detected onCloseActionCancelled event."]];
await context.sync();
});
});
```
isPreview: false
isDeprecated: false
type: interface
methods:
- name: disable()
uid: 'office!Office.BeforeDocumentCloseNotification#disable:member(1)'
package: office!
fullName: disable()
summary: >-
Prevents the notification dialog from appearing when the user attempts to close a document. The
`BeforeDocumentCloseNotification` API is only supported in Excel.
remarks: >-
**Requirement set**: [SharedRuntime
1.2](https://learn.microsoft.com/javascript/api/requirement-sets/common/shared-runtime-requirement-sets)
isPreview: false
isDeprecated: false
syntax:
content: 'disable(): Promise<void>;'
return:
type: Promise<void>
description: ''
- name: enable()
uid: 'office!Office.BeforeDocumentCloseNotification#enable:member(1)'
package: office!
fullName: enable()
summary: >-
Enable a modal notification dialog that appears when the user attempts to close a document. The document won't
close until the user responds. This notification dialog asks the user to confirm the request to close the
document, or allows the user to cancel the request to close the document. The `BeforeDocumentCloseNotification`
API is only supported in Excel.
remarks: >-
**Requirement set**: [SharedRuntime
1.2](https://learn.microsoft.com/javascript/api/requirement-sets/common/shared-runtime-requirement-sets)
isPreview: false
isDeprecated: false
syntax:
content: 'enable(): Promise<void>;'
return:
type: Promise<void>
description: ''
- name: onCloseActionCancelled(handler)
uid: 'office!Office.BeforeDocumentCloseNotification#onCloseActionCancelled:member(1)'
package: office!
fullName: onCloseActionCancelled(handler)
summary: >-
Adds an event handler that detects when the `BeforeDocumentCloseNotification` close operation is cancelled. This
event handler will be triggered if both of the following conditions are met.
1. The add-in calls the `enable` method on the `BeforeDocumentCloseNotification` object.
2. When the notification dialog is open, the end user clicks the **Don't close** button within the dialog,
clicks the Close button in the upper right corner of the dialog, or presses the Esc key.
The `BeforeDocumentCloseNotification` API is only supported in Excel.
remarks: >-
**Requirement set**: [SharedRuntime
1.2](https://learn.microsoft.com/javascript/api/requirement-sets/common/shared-runtime-requirement-sets)
isPreview: false
isDeprecated: false
syntax:
content: |-
onCloseActionCancelled(
handler: () => void
): Promise<() => Promise<void>>;
parameters:
- id: handler
description: The event handler that is called when the dialog is cancelled.
type: () => void
return:
type: Promise<() => Promise<void>>
description: A promise that resolves when the event handler is added.