Sample: Import a Word document template with a Word add-in
Članak
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.
Izvor za ovaj sadržaj možete pronaći na GitHubu, gdje možete stvarati i pregledavati probleme i zahtjeve za povlačenjem. Dodatne informacije potražite u našem vodiču za suradnike.
Povratne informacije o proizvodu Office Add-ins
Office Add-ins je projekt otvorenog koda. Odaberite vezu za slanje povratnih informacija:
Demonstrate that you have the skills needed to get the most out of Word (Microsoft 365 Apps) by earning a Microsoft Office Specialist (MOS) certification.