-
Notifications
You must be signed in to change notification settings - Fork 120
Description
I'm working on a project that requires access to the Custom Properties of a Workbook. i.e.
context.workbook.properties.custom;
I need to check to see if there are any Custom Properties in the workbook when I load the TaskPane.
My project works with Word Desktop, Word Online, Excel Desktop however produces an error in Excel Online.
I have created a sample project to demonstrate this problem. I need to test to see if there are any custom properties with a workbook.
I have a Custom properties Object, the Custom Properties are loaded then a general Exception error is thrown when context.sync is run.
Error: GeneralException: There was an internal error while processing the request.
Expected Behavior
When opening a Workbook with either, no custom properties, (i.e. a New Workbook) or an existing workbook with Custom properties, the expected
behaviour is that the Custom Properties are loaded into the object, as is demonstrated when using Word Desktop, Word Online or Excel Desktop.
Current Behavior
I can successfully load Custom Properties from Word Desktop, Word Online or Excel Desktop. This can be from a blank Document/Workbook or a Document/Workbook that currently has custom properties.
I currently receive the General Exception Error when using Excel Online, NOT Word Desktop, Word Online or Excel Desktop.
Steps to Reproduce, or Live Example
Below is a sample of my code from my sample TaskPane. The error will be reproduced when the TestCustomProperty() function is called.
(function () {
"use strict";
var cellToHighlight;
var messageBanner;
var applicationHostName;
var sHostAPI = "Unsupported"; //Set the host application being used, e.g. Excel or Word
// The initialize function must be run each time a new page is loaded.
Office.initialize = function (reason) {
$(document).ready(function () {
// Initialize the FabricUI notification mechanism and hide it
var element = document.querySelector('.ms-MessageBanner');
messageBanner = new fabric.MessageBanner(element);
messageBanner.hideBanner();
if (Office.context.requirements.isSetSupported('WordApi', 1.3) === true) {
sHostAPI = "WordAPI";
applicationHostName = Word;
}
else if (Office.context.requirements.isSetSupported('ExcelApi', 1.6) === true) {
sHostAPI = "ExcelAPI";
applicationHostName = Excel;
}
//Check to see if the Host is Supported, return a message if it is not.
if (sHostAPI === "Unsupported") {
app.showNotification("Add-in Not Available", "The App is not available for this Office Application.");
$('#TaskPaneBody').prop('disabled', true);
} else {
$('#button-text').text("Test");
$('#button-desc').text("Test Custom Properties");
// Add a click event handler for the highlight button.
$('#test-button').click(TestCustomProperty);
}
});
};
function TestCustomProperty() {
//Get the custom property and select it in the list on start up.
applicationHostName.run(function (context) {
var countOfCustomProperty;
if (sHostAPI === "WordAPI") {
var customProperty = context.document.properties.customProperties;
}
else if (sHostAPI === "ExcelAPI") {
var customProperty = context.workbook.properties.custom;
}
customProperty.load();
countOfCustomProperty = customProperty.getCount();
return context.sync()
.then(function () {
showNotification("Custom Property Count", countOfCustomProperty.value);
});
})
.catch(errorHandler);
}
// Helper function for treating errors
function errorHandler(error) {
// Always be sure to catch any accumulated errors that bubble up from the Excel.run execution
showNotification("Error", error);
console.log("Error: " + error);
if (error instanceof OfficeExtension.Error) {
console.log("Debug info: " + JSON.stringify(error.debugInfo));
}
}
// Helper function for displaying notifications
function showNotification(header, content) {
$("#notification-header").text(header);
$("#notification-body").text(content);
messageBanner.showBanner();
messageBanner.toggleExpansion();
}
})();
Context
We are trying to create a single Add-in that can be used across Word and Excel, both Online and Desktop version.
My add-in works sucessfully in Word Desktop, Online and Excel Desktop, however not Excel Online. Without being able to target Excel Online, we will be limiting the potential of our Add-in.
Your Environment
- Platform [PC desktop, Mac, iOS, Office Online]: Office Online
- Host [Excel, Word, PowerPoint, etc.]: Word and Excel
- Office version number: Office 365 Build 1805, Office Online
- Operating System: Windows 10
- Browser (if using Office Online): IE Version 11 and Chrome 67.0.3396.87
Useful logs
- Console errors
Home.js:78 Error: GeneralException: There was an internal error while processing the request.
Home.js:80 Debug info: {"code":"GeneralException","message":"There was an internal error while processing the request.","errorLocation":"","statement":"custom.load();","surroundingStatements":["var workbook=context.workbook;","var properties=workbook.properties;","var custom=properties.custom;","// >>>>>","custom.load();","// <<<<<","custom.getCount();"],"fullStatements":["Please enable config.extendedErrorLogging to see full statements."]}