Learn Setup Windows Office Word Webapp - aliconnect/aliconnect.sdk GitHub Wiki

Create Word web add-in

Introductie Word web add-in

Maak een gedeelde werkmap

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

Shared folder op je eigen locale PC

  1. Maak een folder aan op je locale computer
  2. Ga naar eigenschappen en deel deze folder als bijvoorbeeld netshare

Shared folder op het netwerk

  1. Maak een folder aan op het netwerk

Maak een XML Manifest file

  1. Maak een file in netshare genaamd app1.xml
  2. Wijzig de file conform het voorbeeld met je eigen gegevens
  3. 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

Voeg de web-api folder toe aan MS-Word

  1. Open MS-Word
  2. Selecteer Bestand
  3. Selecteer Opties
  4. Selecteer Vertrouwenscentrum
  5. Selecteer Instellingen voor het Vertrouwenscentrum
  6. Selecteer Vertrouwde catalogi voor invoegtoepassingen
  7. URL van catalogus: \\localhost\netshare
  8. Selecteer: Weergeven in menu
  9. Klik Catalogus toevoegen
  10. Klik OK
  • Uw instellingen zijn opgeslagen ...
  1. Klik OK
  2. Sluit MS-Word af en start deze opnieuw op

Actveren Add-In

  1. Maak een nieuw document aan
  2. Menu: Invoegen / Invoegtoepassingen / Mijn invoegtoepassingen
  3. Selecteer GEDEELDE MAP
  4. Selecteer de gewenste web applicatie
  5. De web applicatie wordt rechts van het document getoond.

Voor ontwikkelaars

Maak een home.html

<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) { }
⚠️ **GitHub.com Fallback** ⚠️