10 Replies Latest reply on Jun 23, 2012 12:02 PM by Wayne Matus

    Protect the Documents!

    Tim Dexter

      Has anyone written a macro that protects specific fields used by EPDM (via a template) on an EPDM-genereated document (Word)?

       

      I'd like to keep users from deleting/modifying the fields used by the EPDM template, but still allow the macros to update the values via EPDM. I understand the entire document can be protected, but the Auto Open and Update macros will not run.

       

      My thought is to let the macro unlock the protected fields, update them, then lock them again. Is this possible?

       

      Thanks in advance,

       

      Tim

        • Re: Protect the Documents!
          Jason Capriotti

          What kind of fields?

           

          Ours are in the header and footer. While not protected.....the users aren't likely to go there.

            • Re: Protect the Documents!
              Tim Dexter

              In the header and footer as well as in the body of the document. Also, a similiar approach is desired to cover Excel docs.

               

              I realize most people will not bother with these fields, but in the event that they do, it could be pretty messy.

               

              Thanks,

               

              Tim

                • Re: Protect the Documents!
                  Jason Capriotti

                  Well, you can always restore previous versions easy enough if something does get messed up. You can train the users not to....and you have a history of who did it.

                   

                  Excel gives you more options to protect sheets or the entire workbook along with indivdual cells. I have some cells linked to a named range on another sheet called "Data" which are linked to the custom properties that PDM writes to. The cells on the document that are linked have data validation set on them with a popup to prevent users from typing anything other than the formula (example: =Revision).....although it doesn't prevent them from deleting the cells......we have to be flexible enough to allow the users to format the document however it's needed. They can relink the cells up to one of the standard named ranges.

              • Re: Protect the Documents!
                Brian Dalton

                I've been doing this very thing with an Excel document.

                 

                You can set each cell (or selected range of cells) to either Locked (it will not be editable) or not, and then if the sheet is protected, those with the Locked property set will be protected, those without will not.

                 

                To set this property, select a cell, right-click and select Format Cells, go to the Protection tab and check or un-check the box.

                 

                You then protect the sheet using your chosen password, and have your macro unprotect the sheet before changing cells, then re-protect it afterward:

                 

                ActiveSheet.Unprotect SHEETPASS

                 

                ActiveSheet.Protect SHEETPASS

                 

                where SHEETPASS is, of course, your password.  With this solution the password is coded into the macro, so could actually be accessed by someone with the knowledge, but for my purposes it's enough to make it difficult, as I don't forsee any users maliciously desiring to mess with the fields (what would be the gain?) and there's actually only 2 other guys here who might have some idea of how to get into a macro or would ever conceive that it might contain a password.

                 

                Hope this helps.