1

I used this Microsoft tutorial to build a WORD add-in in VS2017. The add-in works as expected. Then, for a test, I dded a button btnTest in Home.html file's task pane markup. The btnTest calls the following function in Home.js. When you click the btnTest button in task pane the first line of the code (now commented out) opens the specified url in a browser but the second line does nothing. How can I make displayDialogAsync(…) work here? I'm using Office 2016 desktop version:

function MyTestMethod() {

     //window.open('http://localhost:50900/home.html');
     Office.context.ui.displayDialogAsync('http://localhost:50900/home.html');
}
nam
  • 21,967
  • 37
  • 158
  • 332

1 Answers1

2

General troubleshooting advice: Please add a callback parameter to the call of displayDialogAsync. An AsyncResult object is passed to the callback. In the body of the callback read the AsyncResult.status and AsyncResult.error properties and log them to the console. This will tell you what's going wrong.

In this case, you are using the http protocol. The help topic that you linked to says that https is required.

I strongly recommend that everyone read through this article before working with the Dialog API: Dialog API in Office Add-ins.

Rick Kirkham
  • 9,038
  • 1
  • 14
  • 32
  • 2
    But I downloaded [this](https://github.com/OfficeDev/Office-Add-in-Dialog-API-Simple-Example) sample from GitHub into `VS2017` where also `IISExpress` is running with no SSL and it successfully displays dialog box when following method is called `function openDialog() { Office.context.ui.displayDialogAsync(window.location.origin + "/Dialog.html", { height: 50, width: 50 }, dialogCallback); }` – nam Oct 23 '18 at 03:56
  • 1
    The ReadMe for that sample says to use HTTPS when you are not using VS. The only reason it doesn't specify this for VS is because an Office Add-in project created for VS uses HTTPS automatically. The [.proj](https://github.com/OfficeDev/Office-Add-in-Dialog-API-Simple-Example/blob/master/SimpleDialogSampleWeb/SimpleDialogSampleWeb.csproj) file says `True`. – Rick Kirkham Oct 24 '18 at 00:39