Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-26-2015, 06:17 AM
rgburridge rgburridge is offline Cant type into content controls in a form after protecting document using macro Windows XP Cant type into content controls in a form after protecting document using macro Office 2007
Novice
Cant type into content controls in a form after protecting document using macro
 
Join Date: Jan 2015
Posts: 3
rgburridge is on a distinguished road
Default Cant type into content controls in a form after protecting document using macro


Hi there

I have a table in a word document that has contentcontrols in each cell. Some are some dropdowns and some are richtext content controls.These are all working well

I want the document to be protected but have some macros which sort and add rows to the table so have to briefly unprotect the document to run these when they are selected.
When I use the

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

line to re-protect the document once the macro has run, it does protect the document again, but a bit too well! I am finding this glitch where I cannot type into the richtext content control boxes. If I click somewhere else on the document first, then reselect the cell with the contentcontrol I can type freely, but directly after the macro has run, I cannot type into these fields.

Anyone know what I am doing wrong? Is annoyingly close to working beautifully!

Many thanks

Richard
Reply With Quote
  #2  
Old 01-26-2015, 08:05 AM
gmaxey gmaxey is offline Cant type into content controls in a form after protecting document using macro Windows 7 32bit Cant type into content controls in a form after protecting document using macro Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

I can't reproduce your problem here. Creating a table with CCs and running

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
On Error Resume Next
ActiveDocument.Unprotect
MsgBox "Test"
ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub
Runs without issue and I can type in all CCs.

Maybe you could try using editable regions and:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
On Error Resume Next
ActiveDocument.Unprotect
MsgBox "Test"
ActiveDocument.Protect wdAllowOnlyReading
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 01-26-2015, 12:09 PM
rgburridge rgburridge is offline Cant type into content controls in a form after protecting document using macro Windows XP Cant type into content controls in a form after protecting document using macro Office 2007
Novice
Cant type into content controls in a form after protecting document using macro
 
Join Date: Jan 2015
Posts: 3
rgburridge is on a distinguished road
Default

Thanks for that. Interestingly it seems the problem only occurs when the macro is run from a command button on the page. If I run it from a button on the quick access toolbar it seems to work, but when from the commandbutton I get the same thing, ie I can't type in the CCs until I have re-clicked elsewhere on the page first. . I had not realised there was a difference when I posted the query, so I guess my follow up question is why does this situation change when the macro is run from a commandbutton on the page? I assume there is some issue around what is 'selected' but I don't know enough to be able to 're-select' the table after locking so I can type into the CCs.

I am running the macro using the call function for the command buttons btw:

Private Sub CommandButton21_Click()
Call Project.LockUnLock

End Sub

Many thanks
Reply With Quote
  #4  
Old 01-26-2015, 04:08 PM
gmaxey gmaxey is offline Cant type into content controls in a form after protecting document using macro Windows 7 32bit Cant type into content controls in a form after protecting document using macro Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Don't know what to say. It appears to be a bug. If you step through the code with the VBE it works with out locking up the CCs.

Again if you use NoChanges (Read Only) as your protection method and make the CCs editable regions it will work.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 01-27-2015, 02:37 PM
rgburridge rgburridge is offline Cant type into content controls in a form after protecting document using macro Windows XP Cant type into content controls in a form after protecting document using macro Office 2007
Novice
Cant type into content controls in a form after protecting document using macro
 
Join Date: Jan 2015
Posts: 3
rgburridge is on a distinguished road
Default

Ok many thanks for looking at it for me
Have done it with legacy form fields in the end. Seems a shame to step back but got the job done!
Thanks again
Reply With Quote
Reply

Tags
protected view



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating and using a template (online form with content controls) Esme Word 2 10-17-2014 07:18 AM
Cant type into content controls in a form after protecting document using macro Updating an old form with Content Controls Something Anon Word 4 03-26-2014 03:53 PM
Disabling content controls and protecting document sections. Catty Word VBA 2 11-29-2013 05:10 AM
Macro to link 2 content controls bortonj88 Word VBA 2 08-21-2012 06:24 AM
Content Controls Form Programming beachdog Word VBA 4 09-20-2011 10:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:44 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