• Release History
  • Documentation
  • Back to www.mscrm-addons.com
  • Release History
  • Documentation
  • Back to www.mscrm-addons.com
home/Knowledge Base/Template Designer(DCP)/How to protect documents with a macro DocX

How to protect documents with a macro DocX

296 views 0 Updated on July 27, 2022

Protection for generated documents is a common query from our customers. With DocX and Macros it is very simple to achieve this.

Open the template, add the following Macro to the template and save it with the file extension .Docm.

Sub DCPMacro()
	ActiveDocument.Protect Password:="password", NoReset:=True, Type:=wdAllowOnlyReading, _     
           UseIRM:=False, EnforceStylelock:=False   
End Sub

This Macro will ensure that the created document is protected with a password.

The DCPMacro will be called after generating the document.

Other macros you could use are:

Macro-Name when will it will be called from the code
DocumentsCorePackMacroBeforeCreateActivity
this macro will be called before the activity is written to CRM
DocumentsCorePackMacroAfterCreate
this macro will be called after the activity is successfully created

Example:

If you want the Document Information Panel to be visible, you could add the following Macro (which will be executed before the activity is created and saved):

Sub DocumentsCorePackMacroBeforeCreateActivity()
    With Application
        .DisplayDocumentInformationPanel = Not .DisplayDocumentInformationPanel
    End With
End Sub

Here is an example template for the entity account:

DocumentInformationPanel.docm (26.02 kb)

That’s it! We appreciate your feedback! Please share your thoughts by sending an email to support@mscrm-addons.com.

reworkneeded

Was this helpful?

Yes  No
Related Articles
  • Introducing the DocumentsCorePack Template Designer Office Add-In (Beta)
  • Ensuring correct time zone display for DateTime fields
  • How to compare a date-fields with the current date 
  • Create a template for XML or plain text
  • E-Invoicing with DocumentsCorePack
  • How to add content from SharePoint to a document
Latest Articles
  • What Happens After You Deploy AttachmentExtractor: Storage & Cost Savings in Dynamics 365
  • Deploying DocumentsCorePack: Setup, Automation, and Real Business Impact in Dynamics365
  • Introducing the DocumentsCorePack Template Designer Office Add-In (Beta)
  • How to Eliminate Excess Storage Costs in Microsoft Dynamics 365 Without Losing Access to Emails and Attachments
  • 3 Ways DocumentsCorePack Transforms Proposal, Quote, and Contract Creation
Popular Articles
  • DocumentsCorePack Template Designer – Getting Started
  • Step-by-Step: How to configure a One-Click-Action
  • Application Access for Dynamics 365
  • How to find your environment’s unique name in Microsoft Dynamics 365
  • How licenses are counted
Top Rated Articles
  • “Undefined”-labels in Chrome and Edge 114 and higher
  • Important information for Dynamics 365 online customers using DocumentsCorePack and/or AttachmentExtractor
  • How to activate the DocumentsCorePack Connector for PowerApps & Microsoft Flow
  • How to insert Condition Fields in DocumentsCorePack Templates designer
  • How licenses are counted
Categories
  • *News and General Infos* 64
  • Webinars 45
  • Template Designer(DCP 197
  • DocumentsCorePack(DCP 259
  • TelephoneIntegration (TI 65
  • AttachmentExtractor (AE 75
  • PowerSearch (PS 50
  • ActivityTools (AT 61
  • SmartBar (SB 54
  • GroupCalendar (GC 47
Our Vision

“We see it as our purpose to provide products that simplify and speed up our customers’ Microsoft Dynamics 365 experience.”

Knowledgebase
LogIn
mscrm-addons.com
  • Products
  • Online Shop
  • Downloads
  • My Account
About Us
  • About Us
  • Case Studies
  • Newsletter
  • Partner Program
  • Contact
Support
  • Support
  • Terms & Conditions
  • Documentation
  • Webinars
  • Legal Documents
  • Impressum
  • © 2022 www.mscrm-addons.com. All Rights Reserved.