1

I'm developing an MS Word Add-In. I've tested it on both Windows and Mac, and it works fine for me. Microsoft requires its own validation of Add-Ins to make sure they work correctly, and my Add-In fails for them even though it works for me with the same version of Windows and Word.

I had a phone call with the Microsoft Validation team, and their only suggestion was that I post a question on Stack Overflow so here goes!

This is the version of Windows and Word that works for me but fails for the MS Validation team:

  • Windows 10 Pro OS build 18362.295
  • Word 2016 (Version 1908 in particular)

I submitted a very simple add-in to Microsoft for debugging purposes. This simple add-in has only a single button that just opens a web page in the user's default browser.

This is the relevant portion of the manifest:

            <Control xsi:type="Button" id="PB.Home.Button">
              <Label resid="PB.Home.Button.Label"/>
              <Supertip>
                <Title resid="PB.Home.Button.Title"/>
                <Description resid="PB.Home.Button.Desc"/>
              </Supertip>
              <Icon> ... </Icon>
              <Action xsi:type="ExecuteFunction">
                <FunctionName>navigateToWebPage</FunctionName>
              </Action>
            </Control>

This is the entirety of FunctionFile.html:

<!DOCTYPE html>
<html>
<head>
  <title></title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" ></script>
  <script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
  <script src="FunctionFile.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>

This is the entirety of FunctionFile.js:

(function () {
  Office.initialize = function (reason) {};
})();

function navigateToWebPage(event) {
  window.open('https://www.example.com', '_blank');
  event.completed();
}

On my computer, when the button is clicked, a browser tab is opened with the web page, but for the MS Validation team this message appears in the toolbar at the bottom of the Word window

enter image description here

but nothing else happens.

The message "Patent Bots GCP is working on your Examiner Statistics" is generated by Word and not by my add in. "Patent Bots GCP" is the name of the add in and "Examiner Statistics" is the button label (one of the short strings in the manifest).

Any suggestions for how I can find out what is failing for the Microsoft Validation team? They are not able to provide any details about the error other than what I've included here.

I hope a Microsoft engineer sees this and is able to help.

=====

Maybe it is a popup blocker issue? See this: https://www.tek-tips.com/viewthread.cfm?qid=949178

new name
  • 15,861
  • 19
  • 68
  • 114
  • What is the complete build number for Windows 10 that you are using? – Rick Kirkham Sep 05 '19 at 15:46
  • @RickKirkham, Windows 10 Pro OS build 18362.295. Thanks for following up. – new name Sep 05 '19 at 15:55
  • Does the verbiage in the message that the MS team is getting come from your add-in? ("Patent Bots … ") – Rick Kirkham Sep 05 '19 at 16:29
  • @RickKirkham, the message is generated by Word (or maybe by Office.js) and not by my add in. See details in edited question above. – new name Sep 05 '19 at 17:28
  • It might be a problem with asynchronicity. Perhaps the timing works out by luck on your computer, but the `event.completed` runs on the validaton team's computer before the window has completed opening. Searching for "is JavaScript window.open async", I found some interesting resources. For example: https://stackoverflow.com/questions/19026162/javascript-window-open-from-callback. – Rick Kirkham Sep 06 '19 at 20:48
  • @RickKirkham, the validation team's computer never gets to 'event.completed()', and you can tell because the "is working on" message is not removed. There is some error halting execution before that. The link you posted unfortunately doesn't help me. :( – new name Sep 06 '19 at 21:23
  • I'm trying to get some internal help in Microsoft. In the meantime I recommend that you try the answer provided by Daxxy in that SO question that I linked to. The one that uses async/await. If it works on your computer, please submit it to the store. – Rick Kirkham Sep 07 '19 at 01:57
  • @RickKirkham, ok I'll give that a shot. Really appreciate your help here. – new name Sep 07 '19 at 14:59
  • @RickKirkham, I wasn't able to get the async version you linked to working. I updated my question with a complete, simple add-in that works for me but fails for the validation team. – new name Sep 09 '19 at 22:37
  • exactly same problem in My Project web Add-in. In one of the function I used window.open but failed with Microsoft Validation. Later I figured out using the following command passed the Microsoft validation. ` Sign up ` – Ragavan Rajan Sep 11 '19 at 02:12
  • Try ahref in your html instead of writing function in JS/ TS. Let me know if it helps – Ragavan Rajan Sep 11 '19 at 02:13
  • @RagavanRajan, since I'm using a Function rather than a task pane, I'm limited to Javascript only. If MS can't figure this out, then I'll have to switch to a task pane, and you suggestion will help there. Thanks! – new name Sep 11 '19 at 12:18
  • @gaefanl can you please share the entire manifest you sent to the validation team? i tried to repro debugging in Visual Studio, and your add-in behaves as expected. – Juan Balmori Sep 12 '19 at 00:15
  • @gaefan also: why are you not using our dialog API? Office.context.ui.displayDialogAsync('https://myAddinDomain/myDialog.html'); (dont forget to add your domain in the add-domains element https://learn.microsoft.com/en-us/office/dev/add-ins/develop/dialog-api-in-office-add-ins – Juan Balmori Sep 12 '19 at 00:16
  • @gaefan make sense. I have analysed little bit more on this. Window.open is returning `Object expected` error when you package it and submit it for validation. I think this may be the reason they are not getting any even triggered. IE11 is basically not treating it as a BOM object. In my view it is transpiling in to ES5 and it failed. – Ragavan Rajan Sep 12 '19 at 00:32
  • @JuanBalmori can you contact me at jeff.oneill at patentbots.com so we can discuss in more detail? Yes, it works for me as well, and that is the problem. I don't know why it doesn't work for the validation team. I don't want to use the DialogAPI because I want the links to open in the user's default browser instead of within Word. – new name Sep 12 '19 at 01:39
  • @RagavanRajan can you contact me at jeff.oneill at patentbots.com so we can discuss in more detail? Sounds like you are getting closer to understanding the problem, but I don't understand the exact problem or how to fix it. – new name Sep 12 '19 at 01:40

2 Answers2

0

Following up on Ragavan's comment, I did some searching for unexpected behavior of window.open() on IE11 (IE11 is the browser used in MS Word on Windows 10).

I found this other SO question, that noted

In IE on Windows 10 with default settings, if I perform a window.open() against an external internet site from a page on my local machine or a server on my local network, I get null.

that question further noted that

Interestingly, if I turn on "Enable Protected Mode" for the Intranet Zone (so that Protected Mode are the same in the Intranet Zone and Internet Zone), then the problem goes away.

I suspect this explains why my add in works on my Windows 10 computer, but not on the validation team's Windows 10 VM.

Unfortunately, the solution proposed in the answer there (w = window.open('') followed by w.location = url) does not work in the Word add in.

While this doesn't fix my problem, hopefully it leads the way to a solution...

new name
  • 15,861
  • 19
  • 68
  • 114
0

@gaefan. Just adding my answer too if any one will have the same problem in future.

If anyone trying to open the external site from their add-in using JS window.open will end up in Object Expected aka validation failure error definitely by Microsoft. It depends on various factors like Windows 10 Build version, Office version and the Browser used by Add-ins.

So to publish your add-in successfully in the App source:

Note: This method is a workaround . But in near future If the new edge chromium version is released. Browser used by Add-ins will be changed. Then the workaround can be eliminated.

  1. Use Task Pane add-in approach if your want to open any external site from Add-in.
  2. The reason for recommonding Task-pane add-in is you can make utilize the anchor tag in your HTML like below

        <a
        href="https://yourcompany.com/"
        class="button-config"
        target="_blank"
        (click)="performOperation()"
        >Sign up
        </a>
    

The reason for click event is to trigger any analytics function or trigger logs or add your custom logic

  1. This will definitely open the external site without changing any settings on your browser.

  2. If you want to stick on with command based add-in try adding new Action or Control button to open a external site via anchor tag.

Hope it will help some one. Thanks

Ragavan Rajan
  • 4,171
  • 1
  • 25
  • 43
  • Thanks Ragavan. How does one use an Action or Control button to open an external site via anchor tag? I thought these buttons were limited to pure Javascript. – new name Sep 13 '19 at 01:27
  • Hi Jeff. I mean you can add another button in your manifest. Button will still expect JS. But in your JS you can implement any of the two approaches 1. Create anchor elements using DOM and click the created anchor tag. or 2. Your second button can open the task pane and you can have set of any operations inside that. – Ragavan Rajan Sep 13 '19 at 03:54