You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/develop/dialog-api-in-office-add-ins.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ The dialog box always opens in the center of the screen. The user can move and r
27
27
28
28
The Office JavaScript APIs include a [Dialog](/javascript/api/office/office.dialog) object and two functions in the [Office.context.ui namespace](/javascript/api/office/office.ui).
29
29
30
-
To open a dialog box, your code, typically a page in a task pane, calls the [displayDialogAsync](/javascript/api/office/office.ui) method and passes to it the URL of the resource that you want to open. The page on which this method is called is known as the "host page". For example, if you call this method in script on index.html in a task pane, then index.html is the host page of the dialog box that the method opens.
30
+
To open a dialog box, your code, typically a page in a task pane, calls the [displayDialogAsync](/javascript/api/office/office.ui#office-office-ui-displaydialogasync-member(1)) method and passes to it the URL of the resource that you want to open. The page on which this method is called is known as the "host page". For example, if you call this method in script on index.html in a task pane, then index.html is the host page of the dialog box that the method opens.
31
31
32
32
The resource that is opened in the dialog box is usually a page, but it can be a controller method in an MVC application, a route, a web service method, or any other resource. In this article, 'page' or 'website' refers to the resource in the dialog box. The following code is a simple example.
> The `DialogMessageOptions` parameter was added to the `messageParent` method as a required parameter in mid-2021. Older add-ins that send a cross-domain message with the method no longer work until they are updated to use the new parameter. Until the add-in is updated, *in Office on Windows only*, users and system administrators can enable those add-ins to continue working by specifying the trusted domains with a registry setting: **HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\WEF\AllowedDialogCommunicationDomains**. To do this, create a file with a `.reg` extension, save it to the Windows computer, and then double-click it to run it. The following is an example of the contents of such a file.
@@ -363,7 +363,7 @@ For example, your code could use the [Office.onReady or Office.initialize functi
363
363
> [!TIP]
364
364
> The `DialogMessageOptions` parameter was added to the `messageChild` method as a required parameter in mid-2021. Older add-ins that send a cross-domain message with the method no longer work until they are updated to use the new parameter. Until the add-in is updated, *in Office on Windows only*, users and system administrators can enable those add-ins to continue working by specifying the trusted domains with a registry setting: **HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\WEF\AllowedDialogCommunicationDomains**. To do this, create a file with a `.reg` extension, save it to the Windows computer, and then double-click it to run it. The following is an example of the contents of such a file.
<!-- Add to https://learn.microsoft.com/office/dev/add-ins/develop/dialog-api-in-office-add-ins when modal dialog feature is deployed. -->
2
+
3
+
> [!TIP]
4
+
> If the child dialog is the [preview modal dialog](modal-dialog.md), then a call of `messageChild` can't be triggered by user interaction with the add-in's task pane or add-in commands, because user interaction is blocked while the modal dialog is open. So, if your dialog use case requires messaging from the parent to the dialog, you will nearly always need to use the non-modal dialog API. However, calling `Office.context.ui.messageParent` in the dialog triggers the `DialogMessageReceived` event in the parent, and code in the handler for that event can call `messageChild`.
title: Use the Office modal dialog API in your Office Add-ins
3
+
description: Learn the basics of creating a modal dialog box in an Office Add-in.
4
+
ms.date: 04/30/2022
5
+
ms.topic: how-to
6
+
ms.localizationpriority: medium
7
+
---
8
+
9
+
# Use the Office modal dialog API in Office Add-ins (preview)
10
+
11
+
There's a *modal* dialog API available in preview. It shouldn't be used in production add-ins, but we encourage you to experiment with it.
12
+
13
+
[!INCLUDE [Information about using preview APIs](../includes/using-preview-apis-host.md)]
14
+
15
+
When the modal dialog is open, the user experiences the following behavior.
16
+
17
+
- The user can't interact with the Office document.
18
+
- The user can't interact with Office application (for example, Excel or Word).
19
+
- The user also can't interact with any other instances of the same Office application.
20
+
- The user can't interact with the add-in's task pane, if any, or custom add-in commands, if any.
21
+
- Event handlers registered by the add-in do run, but the only events that can occur are those that don't require user interaction with the document, the Office application, or the add-in, other than the dialog itself. For example, calling `Office.context.ui.messageParent` in the dialog triggers the `DialogMessageReceived` event in the parent.
22
+
23
+
Everything in the article [Use the Office dialog API in your Office Add-ins](dialog-api-in-office-add-ins.md), including the **Advanced topics and special scenarios** and **Next steps** sections (and the articles that are linked to in those sections), applies to the modal dialog as well as the non-modal dialog except that the method that opens the modal dialog is [Office.context.ui.displayModalDialogAsync](/javascript/api/office/office.ui#office-office-ui-displaymodaldialogasync-member(1)) instead of [Office.context.ui.displayDialogAsync](/javascript/api/office/office.ui#office-office-ui-displaydialogasync-member(1)). In all the code examples, and the add-in samples linked to in the **Samples** section, you can simply replace calls of `displayDialogAsync` with calls of `displayModalDialogAsync`.
0 commit comments