Consulting

Results 1 to 14 of 14

Thread: Locking the centering of content controls in word

  1. #1
    VBAX Regular
    Joined
    Nov 2015
    Posts
    14
    Location

    Locking the centering of content controls in word

    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

  2. #2
    Set the table cell alignment to centred from the context sensitive Layout tab of the ribbon.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Regular
    Joined
    Nov 2015
    Posts
    14
    Location
    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.

  4. #4
    Are you sure it is the table cell alignment you have set and not the cell content paragraph format?
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  5. #5
    VBAX Regular
    Joined
    Nov 2015
    Posts
    14
    Location
    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.

  6. #6
    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.

    alignment.jpg

  7. #7
    VBAX Regular
    Joined
    Nov 2015
    Posts
    14
    Location
    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:
    alignment after backspace.jpg
    Before backspace:
    alignment before backspace.jpg
    So my concern is can there be a way to lock the content control in the center at all times?

  8. #8
    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.

    Center CC in Table.docm

  9. #9
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    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.
    Greg

    Visit my website: http://gregmaxey.com

  10. #10
    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.

  11. #11
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    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.
    Greg

    Visit my website: http://gregmaxey.com

  12. #12
    VBAX Regular
    Joined
    Nov 2015
    Posts
    14
    Location
    Ah well thank you Greg and MW for this info. Yea I am using 2010 Word. Thanks for your help guys.

  13. #13
    Greg,

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

  14. #14
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    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
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •