News.mscrm-addons.com BlogHello and welcome to our blog! What can we do for you? Are you looking for further technical information or step-by-step instructions to our products? Or would you like to read the latest news on mscrm-addons? Please feel free to browse our blog for detailed information and to share our posts! https://www.mscrm-addons.com/BlogHow to protect documents with a macro DocXhttps://www.mscrm-addons.com/Blog/PostId/9549/protect-document-macro-docxDocumentsCorePack (DCP),DCP 2011Thu, 20 Oct 2011 09:27:00 GMT<p>Protection for generated documents is a common query from our customers. With DocX and Macros it is very simple to achieve this.&nbsp;</p> <p>Open the template, add the following Macro to the template and save it with the file extension .Docm.</p> <pre class="brush: vb;">Sub DCPMacro() ActiveDocument.Protect Password:="password", NoReset:=True, Type:=wdAllowOnlyReading, _ UseIRM:=False, EnforceStylelock:=False End Sub </pre> <p>&nbsp;</p> <p>This Macro will ensure that the created document is protected with a password.</p> <p>The DCPMacro will be called after generating the document.</p> <p>Other macros you could use are:</p> <table border="1" cellspacing="0" cellpadding="2" width="518"> <tbody> <tr> <td valign="top" style="width: 385px;"><strong>Macro-Name</strong></td> <td valign="top" style="width: 131px;">when will it will be called from the code</td> </tr> <tr> <td valign="top" style="width: 386px;"> <div>DocumentsCorePackMacroBeforeCreateActivity</div> </td> <td valign="top" style="width: 131px;">this macro will be called before the activity is written to CRM</td> </tr> <tr> <td valign="top" style="width: 386px;"> <div>DocumentsCorePackMacroAfterCreate</div> </td> <td valign="top" style="width: 131px;">this macro will be called after the activity is successfully created</td> </tr> </tbody> </table> <p>Example:</p> <p>If you want the <em>Document Information Panel</em>&nbsp;to be visible, you could add the following Macro (which will be executed before the activity is created and saved):</p> <pre class="brush: vb;"><div><pre class="brush: vb;">Sub DocumentsCorePackMacroBeforeCreateActivity() With Application .DisplayDocumentInformationPanel = Not .DisplayDocumentInformationPanel End With End Sub </pre> </div> </pre> <p>&nbsp;</p> <p>Here is an example template for the entity account:</p> <p><a href="http://mscrm-addons.com/images/blog/files/2011%2f11%2fDocumentInformationPanel.docm">DocumentInformationPanel.docm (26.02 kb)</a></p> <span style="background-color: #fcfcfc;">That&rsquo;s it!&nbsp;</span><span style="background-color: #fcfcfc;">We appreciate your feedback! Please share your thoughts by sending an email to&nbsp;</span><a href="mailto:support@mscrm-addons.com" style="background-color: #fcfcfc;">support@mscrm-addons.com</a><span style="background-color: #fcfcfc;">.</span>9549