问题
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
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
回答1:
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...
回答2:
@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.
- Use
Task Pane
add-in approach if your want to open any external site from Add-in. The reason for recommonding
Task-pane
add-in is you can make utilize theanchor 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
This will definitely open the external site without changing any settings on your browser.
If you want to stick on with
command based add-in
try adding newAction or Control button
to open a external site via anchor tag.
Hope it will help some one. Thanks
来源:https://stackoverflow.com/questions/57808294/how-to-diagnose-failed-validation-of-word-add-in-when-it-works-on-my-own-setup