Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-12-2018, 10:46 AM
Nikko963 Nikko963 is offline How to unlock header content control in form Windows 7 64bit How to unlock header content control in form Office 2016
Novice
How to unlock header content control in form
 
Join Date: Mar 2018
Posts: 12
Nikko963 is on a distinguished road
Default How to unlock header content control in form

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
Reply With Quote
  #2  
Old 04-12-2018, 02:22 PM
macropod's Avatar
macropod macropod is offline How to unlock header content control in form Windows 7 64bit How to unlock header content control in form Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,927
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 04-12-2018, 08:39 PM
Nikko963 Nikko963 is offline How to unlock header content control in form Windows 7 64bit How to unlock header content control in form Office 2016
Novice
How to unlock header content control in form
 
Join Date: Mar 2018
Posts: 12
Nikko963 is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 04-12-2018, 09:10 PM
Guessed's Avatar
Guessed Guessed is offline How to unlock header content control in form Windows 10 How to unlock header content control in form Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,293
Guessed has much to be proud ofGuessed has much to be proud ofGuessed has much to be proud ofGuessed has much to be proud ofGuessed has much to be proud ofGuessed has much to be proud ofGuessed has much to be proud ofGuessed has much to be proud ofGuessed has much to be proud ofGuessed has much to be proud of
Default

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
Reply With Quote
  #5  
Old 04-12-2018, 11:18 PM
gmayor's Avatar
gmayor gmayor is offline How to unlock header content control in form Windows 10 How to unlock header content control in form Office 2016
Expert
 
Join Date: Aug 2014
Posts: 3,890
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #6  
Old 04-13-2018, 06:50 AM
Nikko963 Nikko963 is offline How to unlock header content control in form Windows 7 64bit How to unlock header content control in form Office 2016
Novice
How to unlock header content control in form
 
Join Date: Mar 2018
Posts: 12
Nikko963 is on a distinguished road
Default

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.
Reply With Quote
  #7  
Old 04-13-2018, 03:08 PM
macropod's Avatar
macropod macropod is offline How to unlock header content control in form Windows 7 64bit How to unlock header content control in form Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,927
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Nikko963 View Post
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'd have thought that's be obvious. If you apply 'No changes (read only)' protection, only ranges marked as range exceptions can be edited (whether content controls or not); and I did say:
Quote:
with the appropriate range exceptions
Solution #3 works quite happily without requiring macros or linked content controls.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Content Control Boxes Print on Completed Form Lambchop6 Word 2 04-05-2017 05:16 PM
How to unlock header content control in form Content Control Field Names/Titles Word Form shammi_raj Word VBA 3 03-10-2016 02:54 AM
How to unlock header content control in form Finding field names in a Word-Form created by content control 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
How to unlock header content control in form Allow Multiple Content Control same cell of form table DeborahBartlett Word 1 01-04-2014 11:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:32 AM.


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