• 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

87 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
  • Office Theme Support of DocumentsCorePack
  • Dynamic Document Properties
  • Switch environments in the DocumentsCorePack Template Designer
  • Working with Field Service Inspection responses
  • Create an inspection report for a Work Order
  • Create an inspection report for a Work Order Service Task
Latest Articles
  • New DocumentsCorePack Connector features for Power Automate
  • Office Theme Support of DocumentsCorePack
  • AssureSign for DocumentsCorePack
  • Dynamic Document Properties
  • How to conditionally remove a watermark in DocumentsCorePack templates
Popular Articles
  • Where do I find the Unique Organization name in Microsoft Dynamics 365?
  • DocumentsCorePack Online Service Configuration
  • mscrm-addons.com Application Access for Dynamics 365 (App Access) – DocumentsCorePack
  • DocumentsCorePack Template Designer – Getting Started
  • Step-by-Step: How to configure a One-Click-Action
Top Rated Articles
  • IMPORTANT information for Dynamics 365 online customers using DocumentsCorePack and/or AttachmentExtractor
  • How to activate the DocumentsCorePack connector for PowerApps & Microsoft Flow
  • Step-by-Step: How to configure a One-Click-Action
  • Online Services: Required Application Permissions
  • How licenses are counted
Categories
  • *News and General Infos* 51
  • Webinars 35
  • Template Designer(DCP 173
  • DocumentsCorePack(DCP 191
  • TelephoneIntegration (TI 65
  • AttachmentExtractor (AE 62
  • PowerSearch (PS 48
  • ActivityTools (AT 59
  • SmartBar (SB 53
  • GroupCalendar (GC 46
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.