Sample: Import a Word document template with a Word add-in
Стаття
Templates enable users to quickly create consistent documents for their organizations. Templates can include company information and other critical details that users need for compliance, legal, or other reasons.
This article features a sample add-in that imports a .docx file to use as a template in a Word document. The add-in replaces the current document's content with the content from the template.
Prerequisites
Office connected to a Microsoft 365 subscription (including Office on the web).
The user chooses a .docx file they'd like to use as a template.
The add-in reads the template .docx file then uses Document.insertFileFromBase64 to replace the current document's content with the content from the template file.
The user can make updates to the content of the current document.
Make it yours
The following are a few suggestions for how you could tailor this sample to your scenario.
Manage user settings
Enable single sign-on (SSO) in an Office Add-in to support persisting user data and settings across multiple documents. If your service provides or hosts a document template library, an authorized user can access and apply a template in their document.
Don't store sensitive information such as authentication tokens or connection strings. Properties in the document aren't encrypted or protected.
Provide templates
Provide personalized or company-approved templates for users. These templates can be made accessible from a shared location as part of an authenticated experience.
You can use content controls, fields, and other components as building blocks in your templates.
Personalize templates
Allow users to personalize or refine templates. For templates that may be useful to others (on their team, in their company, etc.), users can upload to a shared location.
Джерело цього вмісту можна знайти на GitHub, де також можна створювати й переглядати запитання та запити на внесення змін. Докладні відомості наведено в нашому посібнику для співавторів.
Відгук про Office Add-ins
Office Add-ins – це проект із відкритим кодом. Виберіть посилання, щоб надати відгук:
Продемонструйте, що у вас є необхідні навички, щоб максимально ефективно використовувати Word (програми Microsoft 365), отримавши сертифікацію фахівця Microsoft Office (MOS).