Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-05-2021, 05:36 AM
coduetse coduetse is offline VBA for locking all edited content controls after saving word document Windows 10 VBA for locking all edited content controls after saving word document Office 2016
Novice
VBA for locking all edited content controls after saving word document
 
Join Date: Oct 2021
Posts: 3
coduetse is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 10-05-2021, 09:47 PM
Guessed's Avatar
Guessed Guessed is offline VBA for locking all edited content controls after saving word document Windows 10 VBA for locking all edited content controls after saving word document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,975
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
I think it will need to be more complex though to handle check boxes. How is the macro supposed to know that a check box has been completed?

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
Reply With Quote
  #3  
Old 10-06-2021, 12:09 AM
coduetse coduetse is offline VBA for locking all edited content controls after saving word document Windows 10 VBA for locking all edited content controls after saving word document Office 2016
Novice
VBA for locking all edited content controls after saving word document
 
Join Date: Oct 2021
Posts: 3
coduetse is on a distinguished road
Default 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.
Reply With Quote
  #4  
Old 10-06-2021, 04:10 AM
Guessed's Avatar
Guessed Guessed is offline VBA for locking all edited content controls after saving word document Windows 10 VBA for locking all edited content controls after saving word document Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,975
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #5  
Old 10-07-2021, 01:39 AM
coduetse coduetse is offline VBA for locking all edited content controls after saving word document Windows 10 VBA for locking all edited content controls after saving word document Office 2016
Novice
VBA for locking all edited content controls after saving word document
 
Join Date: Oct 2021
Posts: 3
coduetse is on a distinguished road
Default

Thanks for the explanation. I will try other options.
Reply With Quote
Reply



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
VBA for locking all edited content controls after saving word document 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:39 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft