Skip to content

Latest commit

 

History

History
 
 

word-tutorial

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
page_type urlFragment products languages extensions description
sample
office-word-add-in-tutorial
office
office-word
javascript
contentType technologies createdDate
samples
Add-ins
09/20/2023 4:00:00 PM
A completed version of the step-by-step Word tutorial hosted on learn.microsoft.com.

Word Tutorial - Completed

Summary

This sample is the result of completing the Tutorial: Create a Word task pane add-in. It was constructed with the Yeoman generator for Office Add-ins.

The tutorial gives step-by-step instructions on how to add functionality alongside explanations as to why code is being added. Use this sample if you want to explore and try the completed code, or if you need to debug any issues you encountered while following the tutorial.

Features

This sample demonstrates the basics of working with a document in Word. The add-in inserts and replaces text ranges, paragraphs, images, HTML, tables, and content controls. The add-in also shows how to format text and how to manage content with content controls.

Applies to

  • Word on Windows
  • Word on Mac
  • Word on the web

Prerequisites

  • Office connected to a Microsoft 365 subscription (including Office on the web).
  • Node.js version 16 or greater.
  • npm version 8 or greater.

Solution

Solution Author(s)
Learn the basics of Word add-ins Microsoft

Version history

Version Date Comments
1.0 9-20-2023 Initial release

Run the sample

  1. Fork and download this repo.

  2. Go to the Samples/tutorials/word-tutorial/My Office Add-in folder via the command line.

  3. Run npm install.

  4. Run npm run build.

  5. Start the local web server and sideload your add-in.

    • To test your add-in in Word, run the following command in the root directory of your project. This starts the local web server (if it's not already running) and opens Word with your add-in loaded.

      • Windows: npm start
      • Mac: npm run dev-server
    • To test your add-in in Word on the web, run the following command in the root directory of the My Office Add-in project. When you run this command, the local web server starts. Replace "{url}" with the URL of a Word document on your OneDrive or a SharePoint library to which you have permissions.

      npm run start:web -- --document {url}

      The following are examples.

      • npm run start:web -- --document https://contoso.sharepoint.com/:t:/g/EZGxP7ksiE5DuxvY638G798BpuhwluxCMfF1WZQj3VYhYQ?e=F4QM1R
      • npm run start:web -- --document https://1drv.ms/x/s!jkcH7spkM4EGgcZUgqthk4IK3NOypVw?e=Z6G1qp
      • npm run start:web -- --document https://contoso-my.sharepoint-df.com/:t:/p/user/EQda453DNTpFnl1bFPhOVR0BwlrzetbXvnaRYii2lDr_oQ?e=RSccmNP

      NOTE: If you're developing on a Mac, enclose the {url} in single quotation marks. Don't do this on Windows.

      If your add-in doesn't sideload in the document, manually sideload it by following the instructions in Manually sideload add-ins to Office on the web.

  6. If the add-in task pane isn't already open in Word, go to the Home tab and choose the Show Taskpane button in the ribbon to open it.

  7. Use the buttons in the task pane to interact with the document through your add-in. For details on the expected behavior of each button, see the "Test the add-in" sections of the Tutorial: Create a Word task pane add-in.

See also

The version of this sample that you create step-by-step is found in the article Tutorial: Create a Word task pane add-in.

Copyright

Copyright (c) 2023 Microsoft Corporation. All rights reserved.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.