#1
|
|||
|
|||
VBA for locking all edited content controls after saving word document
I am designing word forms with content controls. A single form will be filled by two to three people. Kindly share with me a VBA to lock contents of each content control immediately after the end user edits the respective content control and press save. However, the unedited CCs shall remain editable…This is to ensure that the second user cannot edit changes made by the first user and so on. The CCs in use; Plain text CC, Check box CC, Picture CC, Date Picker CC and Drop down list CC. Thank you. |
#2
|
||||
|
||||
I would start with a macro like this which will run automatically when the user saves the file.
Code:
Sub FileSave() Dim aCC As ContentControl For Each aCC In ActiveDocument.ContentControls aCC.LockContents = Not aCC.ShowingPlaceholderText Next aCC ActiveDocument.Save End Sub This protection method is only as strong as the user's knowledge. If they know how to unlock a CC then they can do so easily.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
VBA for locking all edited content controls after saving word document
Thank you for the prompt response.
The VBA Code answers the question I asked for and I tested it and it works as desired. Is it possible to add a line to your code that disables copying of contents of content control. The target CC is the picture CC. This is to ensure other users cannot copy contents of the picture content control. I have noted that if you protect the document with password, it becomes impractical to unlock the CC unless your have the password to unlock the document and go to design mode>properties and unlock CC. I could be wrong but for me the VBA is good especially if you can add 'disable copying line.' As for check boxes, I will lock for work around. Thank you. |
#4
|
||||
|
||||
For the checkboxes, you can test the type of CC and act accordingly. The question is 'how do we know the checkbox has been completed' - is an empty checkbox a sign of incompletion or a negative answer? If you take a look at this thread you will be able to see how you can test for types of CCs or the CC title or tag properties - https://www.msofficeforums.com/word-...it-macros.html
With the Picture CC, I would recommend you do some testing. I would try setting the CC to 'remove content control after editing'. If you have protected the document for forms, this will make the graphic uneditable since it won't be a CC. I don't know that any protection you come up with is something I would fully trust - it will only stop the honest people. I would be pretty confident I could still extract your picture if you put it in a Word document with some form of protection that still allows me to see it.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
Thanks for the explanation. I will try other options.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
For a Word template: how can I have edited content automatically reappear elsewhere in the document? | olivia | Word | 4 | 02-20-2017 05:06 PM |
Substitute for Content Controls in Word 97 - 2003 Document | taryn | Word | 4 | 02-13-2015 01:30 PM |
More than one content controls in a word document | lucky16 | Word VBA | 6 | 07-10-2014 08:34 AM |
Disabling content controls and protecting document sections. | Catty | Word VBA | 2 | 11-29-2013 05:10 AM |
Using both rich and plain content controls in one document | Erica.Black | Word | 0 | 06-18-2013 10:33 AM |