Answered by:
Bath align center all textboxes in a word document

Question
-
Hi,
Need to align center all textboxes in my document . I can select one textbox , then click align center. But when I select all textboxes and click align center, it doesn't work.
Is there something wrong with my step? Or I have to align center all textboxes one by one? Any other quick ways to do that ?
Thanks in advance.
Friday, April 28, 2017 8:55 AM
Answers
-
You could run the following macro. If you create the macro in a module in your default template Normal.dotm, you can use it in any document where you need it.
Sub CenterTextBoxes() Dim shp As Shape Application.ScreenUpdating = False For Each shp In ActiveDocument.Shapes If shp.Type = msoTextBox Then shp.TextFrame.TextRange.ParagraphFormat _ .Alignment = wdAlignParagraphCenter End If Next shp Application.ScreenUpdating = True End Sub
Regards, Hans Vogelaar (http://www.eileenslounge.com)
- Proposed as answer by Winnie LiangMicrosoft contingent staff Monday, May 1, 2017 2:57 AM
- Marked as answer by LydiaLD Wednesday, May 3, 2017 3:09 AM
Friday, April 28, 2017 9:20 AM -
Hi,LydiaLD
You can use the macro to do that as above reply.
And as you may need to center all pictures too, you can try the macro as below.
Sub CenterInLinePicturesAndTextBoxes() Dim objInLineShape As InlineShape Dim objShape As Shape Dim objDoc As Document Set objDoc = ActiveDocument For Each objInLineShape In objDoc.InlineShapes objInLineShape.Select Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter Next objInLineShape For Each objShape In objDoc.Shapes If objShape.Type = msoTextBox Then objShape.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage objShape.Left = wdShapeCenter End If Next objShape End Sub
More details, please see here:
https://www.datanumen.com/blogs/2-methods-center-pictures-text-boxes-word-document/
Hope it helps.- Marked as answer by LydiaLD Wednesday, May 3, 2017 3:09 AM
- Edited by LotusAdaBanned Friday, May 12, 2017 1:20 AM
Tuesday, May 2, 2017 4:26 AM
All replies
-
You could run the following macro. If you create the macro in a module in your default template Normal.dotm, you can use it in any document where you need it.
Sub CenterTextBoxes() Dim shp As Shape Application.ScreenUpdating = False For Each shp In ActiveDocument.Shapes If shp.Type = msoTextBox Then shp.TextFrame.TextRange.ParagraphFormat _ .Alignment = wdAlignParagraphCenter End If Next shp Application.ScreenUpdating = True End Sub
Regards, Hans Vogelaar (http://www.eileenslounge.com)
- Proposed as answer by Winnie LiangMicrosoft contingent staff Monday, May 1, 2017 2:57 AM
- Marked as answer by LydiaLD Wednesday, May 3, 2017 3:09 AM
Friday, April 28, 2017 9:20 AM -
Hi. guys
Thanks for all your time and help. Appreciate it!
Wednesday, May 3, 2017 3:12 AM