OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 96 forks source link

“Word object is undefined” error when executing Word.run function #100

Closed RoyalMugu closed 6 months ago

RoyalMugu commented 6 years ago

Message from office-js bot: We’re closing this issue because it has been inactive for a long time. We’re doing this to keep the issues list manageable and useful for everyone. If this issue is still relevant for you, please create a new issue. Thank you for your understanding and continued feedback.

We have developed a Word javascript addin which makes use of Word Api 1.2. We are loading this addin in Office 2016 MSI.   The web application of the addin is hosted at their internal server, we can access it through the intranet. The Manifest is kept in a Shared drive. Our intention is to make this addin work in an environment which doesn’t have an internet connection.   Whenever the addin tries to execute the Word.run() function, we get “Word object is undefined” error in the internet explorer console. This issue occurs only when there is no internet connection. When the machine is connected to internet, they don’t see this issue.   Looking at the network trace during this API call, we see word -15.01.js when they run it without internet and word -win32-16.00.js when they run it with internet connection. we have kept all the .js files and packages in the same internal server where we have hosted their web application.   I know loading a web addin without internet connection is a bad idea . But we are a banking company and we don’t want our machines to be connected to the internet.

Expected Behavior

The addin should work without internet connection

Current Behavior

We are getting “Word object is undefined” error when executing Word.run function Looking at the network trace during this API call, we see word -15.01.js when they run it without internet and word -win32-16.00.js when they run it with internet connection. we have kept all the .js files and packages in the same internal server where we have hosted their web application.

Steps to Reproduce, or Live Example

Word.run(function (context) {

      return context.sync();
    })
    .catch(errorHandler);

Context

Unable to deploy this addin to the word client. The addin has to work without internet connection

Your Environment

Useful logs

JuaneloJuanelo commented 6 years ago

can you describe how you got your own copy of Office.js?

JuaneloJuanelo commented 6 years ago

BTW Word 1.2 is not supported in MSI, you can only do 1.1 APIs.

RoyalMugu commented 6 years ago

Run this code in Script lab and you will get a success ( add the script lab addin in Word 2016 MSI) async function run() {

if (Office.context.requirements.isSetSupported('WordApi', 1.2)) {
    console.log("Success");
}
else {
    console.log("This add-in requires Word 2016 or greater.");
}

}

RoyalMugu commented 6 years ago

According to this documentation, it says MSI only supports Word api1.1 but it appears that ap1.2 is also supported. I am surprised. https://dev.office.com/reference/add-ins/requirement-sets/word-api-requirement-sets?product=word

We got the Office.js files through Nuget packages. These packages are kept in a file share and loaded from that location. https://www.nuget.org/packages/Microsoft.Office.js/

JuaneloJuanelo commented 6 years ago

I can tell you with 100% certainty that 1.2 is not supported in MSI, we have not backported any investments since 1.2 to MSI and the documentation is also 100% accurate. The problem with "ScriptLab" is that it loads Office.js in a very special (and now MSI-buggy) way, and we are actually working on a fix. So right now do not trust script lab in MSI.

You are getting the files from the right location. And probably there is an issue when using those libraries in MSI builds.

Another question: for the reasons I am explaining above: why do you need to update Office.js if you are in MSI? (you will not get the benefits of 1.2 or 1.3 because of the builds in your environment)

JuaneloJuanelo commented 6 years ago

@Zlatkovsky Apparently the npm-generated Office.js seems not to work in MSI builds. apparently is incorrectly reporting that Word 1.2 is supported there (and it does not)

JuaneloJuanelo commented 5 years ago

@Zlatkovsky this is an issue with the Office.js package, if you no longer own this, please assign to who currently owns it now. thanks!

Zlatkovsky commented 5 years ago

@wandyezj owns that space now.

ndvbd commented 3 years ago

I see this problem of "Word undefined" in Word 2013, but I don't see it in Word 365. Any progress here? There are many users with Word 2013.