Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.Office.js window.external.GetContext()

Tags:

office-js

This has been beating me for a few hours now and it's time to ask.

I have ran the Apps for Office tutorial inside Visual Stutio and it works fine -- I can see the Task Pane in excel with all buttons and functions properly.

However, I'm trying to integrate Apps for Office into our existing MVC project. All comes up and I can see the Apps for Office page in the browser but then get Undefined is not a function in the following Microsoft.Office.js module snippet while doing window.external.GetContext():

OSF.InitializationHelper.prototype.getAppContext=function      OSF_InitializationHelper$getAppContext(wnd, gotAppContext) {
    if (this._hostInfo.isRichClient) {
        var returnedContext;
        **var context=window.external.GetContext();**
        var appType=context.GetAppType();
        var appTypeSupported=false;

Any ideas?

like image 785
webteckie Avatar asked Nov 10 '22 03:11

webteckie


1 Answers

An old question but still worth answering for anyone who might find this in a search.

One important note, "Apps for Office" has since been renamed "Office Web Add-ins". The architectural modal remains the same, it is purely a name change.

Add-ins are intended to extend the functionality of Office applications (Word, PowerPoint, Excel, Outlook, Project, etc.). They are designed to operate within the context of an Office app and running them outside that context (i.e. opening the add-in directly in a browser) will result in a number of errors. The getAppContext function for example is attempting to get ahold of the Office application instance, since this is running outside of Office there is no "App Context" available.

like image 99
Marc LaFleur Avatar answered Jan 04 '23 01:01

Marc LaFleur