Learn Setup Windows Office Word Webapp - aliconnect/aliconnect.sdk GitHub Wiki
Introductie Word web add-in
Voor het gebruik van word add-ins dien je een gedeelde werkmap te hebben op het netwerk. Hierin staan configuratie bestanden van ieder web-add-in
- Maak een folder aan op je locale computer
- Ga naar eigenschappen en deel deze folder als bijvoorbeeld
netshare
- Maak een folder aan op het netwerk
- Maak een file in
netshare
genaamdapp1.xml
- Wijzig de file conform het voorbeeld met je eigen gegevens
- Voor iedere applicatie kan je een eigen file maken. Iedere applicatie heeft altijd een eigen unieke
Id
nodig
<?xml version="1.0" encoding="utf-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="TaskPaneApp">
<Id>d097fa05-e4a4-4d22-9950-adf7fa60e6b6
<Version>1.0
<ProviderName>Alicon
<DefaultLocale>NL-NL
<DisplayName DefaultValue="Aliconnect"/>
<Description DefaultValue="Aliconnect web integratie"/>
<Hosts>
<Host Name="Document"/>
<Host Name="Workbook"/>
<DefaultSettings>
<SourceLocation DefaultValue="https://aliconnect.nl/word/home.html" />
<Permissions>ReadWriteDocument
- Open MS-Word
- Selecteer
Bestand
- Selecteer
Opties
- Selecteer
Vertrouwenscentrum
- Selecteer
Instellingen voor het Vertrouwenscentrum
- Selecteer
Vertrouwde catalogi voor invoegtoepassingen
- URL van catalogus:
\\localhost\netshare
- Selecteer:
Weergeven in menu
- Klik
Catalogus toevoegen
- Klik
OK
- Uw instellingen zijn opgeslagen ...
- Klik
OK
- Sluit MS-Word af en start deze opnieuw op
- Maak een nieuw document aan
- Menu:
Invoegen
/Invoegtoepassingen
/Mijn invoegtoepassingen
- Selecteer
GEDEELDE MAP
- Selecteer de gewenste web applicatie
- De web applicatie wordt rechts van het document getoond.
<html class="app">
<head>
<title>Word Home
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" charset="UTF-8" src="https://aliconnect.nl/api/js/lib/jquery.js" >
<script type="text/javascript" charset="UTF-8" src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" >
<script type="text/javascript" charset="UTF-8" src="https://aliconnect.nl/api/js/config">
<script type="text/javascript" charset="UTF-8" src="https://aliconnect.nl/api/js/aim.js">
<script type="text/javascript" charset="UTF-8" src="https://aliconnect.nl/api/js/web.js">
<body>
<div id="content-header">
<div class="padding">
# Welcome
<div id="content-main">
<div class="padding">
<button id="readall">Read all
<br />
<div id="step">
<pre id="content">
<pre id="contentText">
<div id="contentHTML">
<div id="supportedVersion">
<script type="text/javascript" charset="UTF-8" src="home.js" >
'use strict';
// data = [];
(function () {
Office.onReady(function() {
// Office is ready
$(document).ready(function () {
// The document is ready
// Use this to check whether the API is supported in the Word client.
if (Office.context.requirements.isSetSupported('WordApi', '1.1')) {
var data = [];
// Do something that is only available via the new APIs
$('#emerson').click(insertEmersonQuoteAtSelection);
$('#checkhov').click(insertChekhovQuoteAtTheBeginning);
$('#proverb').click(insertChineseProverbAtTheEnd);
$('#readall').click(readall);
$('#supportedVersion').html('This code is using Word 2016 or later.');
}
else {
// Just letting you know that this code will not work with your version of Word.
$('#supportedVersion').html('This code requires Word 2016 or later.');
}
});
});
function insertEmersonQuoteAtSelection() {
Word.run(function (context) {
// Create a proxy object for the document.
var thisDocument = context.document;
// Queue a command to get the current selection.
// Create a proxy range object for the selection.
var range = thisDocument.getSelection();
// Queue a command to replace the selected text.
range.insertText('"Hitch your wagon to a star."\n', Word.InsertLocation.replace);
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
return context.sync().then(function () {
console.log('Added a quote from Ralph Waldo Emerson.');
});
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
}
function insertChekhovQuoteAtTheBeginning() {
Word.run(function (context) {
// Create a proxy object for the document body.
var body = context.document.body;
// Queue a command to insert text at the start of the document body.
body.insertText('"Knowledge is of no value unless you put it into practice."\n', Word.InsertLocation.start);
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
return context.sync().then(function () {
console.log('Added a quote from Anton Chekhov.');
});
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
}
function insertChineseProverbAtTheEnd() {
Word.run(function (context) {
// Create a proxy object for the document body.
var body = context.document.body;
// Queue a command to insert text at the end of the document body.
body.insertText('"To know the road ahead, ask those coming back."\n', Word.InsertLocation.end);
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
return context.sync().then(function () {
console.log('Added a quote from a Chinese proverb.');
});
})
.catch(function (error) {
console.log('Error: ' + JSON.stringify(error));
if (error instanceof OfficeExtension.Error) {
console.log('Debug info: ' + JSON.stringify(error.debugInfo));
}
});
}
})();
try {
Office.initialize = function (reason) {
if (Office.context.requirements.isSetSupported('WordApi', 1.1)) {
supportedVersion.innerText = 'OK';
// mswordapi = true;
} else {
supportedVersion.innerText = 'This code requires Word 2016 or greater.';
}
};
} catch (err) { }