I was tasked to adding an additional feature to our Word Addin.
We are trying to add custom shortcuts.
I have used the code that was given on https://docs.microsoft.com/en-us/office/dev/add-ins/design/keyboard-shortcuts#configure-the-manifest and when using the code I get the error: Property 'actions' does not exist on type 'typeof Office'
Here is what the code looks like:
Office.actions.associate('SHOWTASKPANE', function () {
return Office.addin.showAsTaskpane()
.then(function () {
return;
})
.catch(function (error) {
return error.code;
});
});
I have gone through the Office.js file and I cant see if anything is missing.
Your help would really be appreciated
May add these functions to the global scope and don`t use action will help for you.
function getGlobal() {
return typeof self !== "undefined"
? self
: typeof window !== "undefined"
? window
: typeof global !== "undefined"
? global
: undefined;
}
let g = getGlobal()
g.SHOWTASKPANE= function () {
return Office.addin.showAsTaskpane()
.then(function () {
return;
})
.catch(function (error) {
return error.code;
});
});;
Try this:
npm install @types/office-js --save-dev