PDA

View Full Version : Locking the centering of content controls in word



limdul
11-20-2015, 03:02 PM
Hi,

I am making a document that has multiple tables and within those tables I am having plain text content controls in them. I want them to be centered in each cell. However after the document is protected if you hit the backspace while inside one of the content controls it will revert it to be on the left hand side of the cell. Is there a way to lock them in place to be in the center??

Thanks

gmayor
11-20-2015, 10:18 PM
Set the table cell alignment to centred from the context sensitive Layout tab of the ribbon.

limdul
11-23-2015, 09:05 AM
That is the thing though is that I have set the layout to centered and it is centered but if you backspace with nothing in the text box then it reverts it back to left hand side alignment.

gmayor
11-24-2015, 12:28 AM
Are you sure it is the table cell alignment you have set and not the cell content paragraph format?

limdul
11-24-2015, 08:02 AM
Well now I dont know lol. I am using the centered alignment from the table tools under layout. That centers the textbox but again if you hit backspace with nothing in the textbox it sets the alignment under layout to left hand side.

MacroWizard
11-30-2015, 08:10 PM
limdul,

Make sure you're looking at the right spot. Look at the image below to make sure we're on the same page. Select the entire table, then click the button at the top. When you do that, you can see below that it stays centered when I hit the backspace button a bunch of times.

14853

limdul
12-02-2015, 10:36 AM
Hi Macrowizard,

I have done that. I have selected each cell that will have a plain text content control in it and centered it through the alignment section that you have show. However when I put the content control plain text in there and hit backspace it will move the content control to the left side of the cell and when you go to the alignment section it will show that it is to the left hand side. See photos below:
After backspace:
14858
Before backspace:
14859
So my concern is can there be a way to lock the content control in the center at all times?

MacroWizard
12-02-2015, 05:50 PM
limdul,

I added the table, set the Content Control to be un-deletable. The only thing that I did differently is, when I select the table, I went to Layout (tab) > Select - Table > Then Center Aligned the entire table. My content control shrinks to the center when the contents are deleted. When I type inside the content control, it fills the entire cell but still has centered text. Check it out. :)

14865

gmaxey
12-02-2015, 07:33 PM
MW,

Your document behaves exactly like limdul describes the problem. Open your file, put the cursor in the CC after the end of your "test", hit the backspace key until the text is gone, hit it again and the CC is left aligned. Been that way since Word 2007. If there is a way turn if off, I don't know.

Same thing happens in and empty paragraph. limdul, all you can do is use restricted editing and set your CCs as editable regions.

MacroWizard
12-02-2015, 10:30 PM
Gmaxey,

My document works for me; however, I am using word 2013. I am not sure previous versions are equipped with this fix. No matter how many times I hit backspace inside of the CC, it stays center aligned.

gmaxey
12-03-2015, 04:52 AM
MW,

It is (or I will say can) be as limdul describes in Word versions 2007/2010/2013/2016. The difference is that he/she and I have Options/Proofing/Autocorrect Options/AutoFormat As You Type/Automatically as you type Set left- and first-indent with tabs and backspace checked.

You don't have a "fix," you have an option and limdul has no real control of what option you or I use. The only way to "ensure" it stays put is to use restricted editing with a password and keep a close hold on the password.

limdul
12-03-2015, 08:30 AM
Ah well thank you Greg and MW for this info. Yea I am using 2010 Word. Thanks for your help guys.

MacroWizard
12-05-2015, 02:29 PM
Greg,

Do you think there is a way to uncheck the box and disable it for the document via VBA?

gmaxey
12-05-2015, 03:49 PM
MW,

Yes, but some people won't appreciate you tinkering with their option:


Option Explicit
Private bUserTabIndentKey As Boolean
Sub AutoOpen()
bUserTabIndentKey = Options.TabIndentKey
Options.TabIndentKey = False
lbl_exit:
Exit Sub
End Sub
Sub AutoClose()
Options.TabIndentKey = bUserTabIndentKey
lbl_exit:
Exit Sub
End Sub