|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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 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 |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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. |
#5
|
|||
|
|||
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 |
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 |
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 |