![]() |
#1
|
|||
|
|||
![]()
Hello, everyone. Thanks in advance for your assistance.
I have a multi-page form in Word 2016 which is locked for forms. One of the content control text fields on the cover is for a company's name. I want that name to be inserted into a content control field in the header of the remaining pages. Unfortunately, the code I wrote that worked during the design phase (unlocked doc) DOESN'T work once the document is locked for forms: I get an error message that the content control is locked even though the "Contents cannot be edited" property is successfully unset (unlocked) by the code. If I unlock the document, my code works fine. My script: With Doc.SelectContentControlsByTag("PartnerNameHeader" ).Item(1) .LockContents = False .Range.Text = _ Doc.SelectContentControlsByTag("PartnerName").Item (1).Range.Text .LockContents = True End With So...why does locking the document for forms have some sort of override that is preventing the content control from being edited even if its field properties says it is editable? How can I overcome this? Thanks again. - Nikko |
#2
|
||||
|
||||
![]()
With 'filling in forms' protection, you can't access header/footer content; you can with 'No changes (read only)' protection if the header/footer content control is marked as an exception. You have a number of options:
1. temporarily disable 'filling in forms' protection while updating the header/footer content; 2. switch over to 'No changes (read only)' protection with the appropriate range exceptions 3. apply a unique Style name to your PartnerName content control and, instead of using your PartnerNameHeader content control, use a StyleRef field in the header to reference that Style. PS: with 'filling in forms' protection - even if temporarily disabled - you don't need to lock the content control, because it's inacessible.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Thanks, except that #2 has the same problem in reverse. If I lock with exceptions, then a field within the body of the document which doesn't have an exception cannot be modified by my VB script. (Same error.) So while this might take care of my header problem, since the user can't access the header anyway, it just gives me the same problem for fields elsewhere in my document.
I need to have content control objects within the body of my document and my header whose content can only be set by my VBA script. There will naturally be other CC objects (only within the body of the doc) that the user can modify but the user shouldn't be able to touch anything else. I'll take a look at #1 next... - Nikko |
#4
|
||||
|
||||
![]()
Nikko
Why would you need code to perform the task normally done more simply by using linked content controls? Have you explored linked content controls and discarded them for some reason?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
||||
|
||||
![]()
Mapped and duplicated content controls seem sensible to me too. You could use https://www.gmayor.com/insert_content_control_addin.htm to aid the insertion of mapped controls, then all you have to do is copy and paste the duplicate control to the other location. Whatever you type in one is repeated in the other(s).
If you lock the controls against deletion, there is no need to protect the form. Protection for forms is a very weak form of protection. If people want to screw up your form, they will.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#6
|
|||
|
|||
![]()
Unlocking and re-locking the document for forms in VB did the trick.
As for other kind suggestions: I have no interest in introducing a 3rd-party tool into my company's increasingly paranoid (with some justification) IT security environment. Using a linked document property field hadn't occurred to me, and I will keep this in mind for future projects. For now, this one is already done. I realize that the document protection offered by Word is not really secure, but it is good enough for my current purposes. If the stakeholders in this document want better security, I'll cross that bridge when I get to it. Thanks to all for their input. |
#7
|
||||
|
||||
![]() Quote:
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Content Control Boxes Print on Completed Form | Lambchop6 | Word | 2 | 04-05-2017 05:16 PM |
![]() |
shammi_raj | Word VBA | 3 | 03-10-2016 02:54 AM |
![]() |
shammi_raj | Word | 1 | 03-10-2016 02:37 AM |
making an email form in outlook that has restricted access and uses content control fields | ericc2728 | Outlook | 0 | 08-25-2014 11:19 AM |
![]() |
DeborahBartlett | Word | 1 | 01-04-2014 11:06 AM |