Office.BeforeDocumentCloseNotification interface
ユーザーがドキュメントを閉じようとしたときに表示されるモーダル通知ダイアログを表します。 ユーザーが応答するまでドキュメントは閉じません。 通知ダイアログでは、ドキュメントを閉じる要求を確認したり、ドキュメントを閉じる要求を取り消したりできます。 この API は Excel でのみサポートされています。
注釈
要件セット: SharedRuntime 1.2
使用元
例
// 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();
});
});
メソッド
| disable() | ユーザーがドキュメントを閉じようとしたときに、通知ダイアログが表示されないようにします。
|
| enable() | ユーザーがドキュメントを閉じようとしたときに表示されるモーダル通知ダイアログを有効にします。 ユーザーが応答するまでドキュメントは閉じません。 この通知ダイアログでは、ドキュメントを閉じる要求の確認を求めたり、ドキュメントを閉じる要求をキャンセルしたりすることができます。
|
| on |
|
メソッドの詳細
disable()
ユーザーがドキュメントを閉じようとしたときに、通知ダイアログが表示されないようにします。
BeforeDocumentCloseNotification API は Excel でのみサポートされています。
disable(): Promise<void>;
返品
Promise<void>
注釈
要件セット: SharedRuntime 1.2
例
// Disable the dialog that pops up when the user tries to close the document.
async function disableCloseNotification() {
await Office.addin.beforeDocumentCloseNotification.disable();
}
enable()
ユーザーがドキュメントを閉じようとしたときに表示されるモーダル通知ダイアログを有効にします。 ユーザーが応答するまでドキュメントは閉じません。 この通知ダイアログでは、ドキュメントを閉じる要求の確認を求めたり、ドキュメントを閉じる要求をキャンセルしたりすることができます。
BeforeDocumentCloseNotification API は Excel でのみサポートされています。
enable(): Promise<void>;
返品
Promise<void>
注釈
要件セット: SharedRuntime 1.2
例
// Enable the dialog that pops up and asks the user for confirmation when they try to close the document.
async function enableCloseNotification() {
await Office.addin.beforeDocumentCloseNotification.enable();
}
onCloseActionCancelled(handler)
BeforeDocumentCloseNotification の閉じる操作が取り消されたタイミングを検出するイベント ハンドラーを追加します。 このイベント ハンドラーは、次の両方の条件が満たされた場合にトリガーされます。
アドインは、
BeforeDocumentCloseNotificationオブジェクトのenableメソッドを呼び出します。通知ダイアログが開いているときに、エンド ユーザーはダイアログ内の [ 閉じないでください ] ボタンをクリックするか、ダイアログの右上隅にある [閉じる] ボタンをクリックするか、または Esc キーを押します。
BeforeDocumentCloseNotification API は Excel でのみサポートされています。
onCloseActionCancelled(
handler: () => void
): Promise<() => Promise<void>>;
パラメーター
- handler
-
() => void
ダイアログがキャンセルされたときに呼び出されるイベント ハンドラー。
返品
Promise<() => Promise<void>>
イベント ハンドラーが追加されたときに解決される Promise。
注釈
要件セット: SharedRuntime 1.2