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');
}
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.