In this article, we would like to introduce you with 2 methods to center all pictures and text boxes in your Word document.
Pictures and shapes, such as text boxes, play vital important in making a wonderful document. With a growing number of images and shapes being inserted, the demand to integrate their formatting, say to center them starts to surface.
What you should know is that all pictures inserted into document is set in “In line with text” layout, while text boxes are flowing shapes. You may change the picture layout as required, but to center them you will have to consider the text wrapping. Because text formatting can be easily tampered, leaving you with a layout you don’t like.
Therefore, we will focus on 2 ways to center “In line with text” pictures and text boxes.
Method 1: Center One Picture or Text Box Manually
To center a “In line with text” picture, follow these steps:
- Firstly, click on the picture to select it.
- Secondly, click “Center” in “Paragraph” group under “Home” tab. Or you can use the shortcuts “Ctrl+ E” instead.
Then to center a text box, go through these instructions:
- Similarly, click on text box to have it in selection.
- Then click “Format” tab under “Drawing Tools”.
- Next click “Align” in “Arrange” group.
- And choose “Align Center” on its drop-down menu.
Method 2: Batch Center Multiple Pictures or Text Boxes Automatically
Most of us would favor an automatic process to save efforts. Here you go.
- First off, press “Alt+ F11” to open the VBA editor.
- Next click “Normal” project.
- Click “Insert” tab and choose “Module”.
- Then double click on the module to bring out the editing space on the right side.
- Next to center pictures, you paste the following codes there:
Sub CenterInLinePictures() Dim objInLineShape As InlineShape Dim objDoc As Document Set objDoc = ActiveDocument For Each objInLineShape In objDoc.InlineShapes objInLineShape.Select Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter Next objInLineShape End Sub
To center all text boxes, you need the bellowing macro:
Sub CenterTextBoxes() Dim objDoc As Document Dim objTextBox As Shape Set objDoc = ActiveDocument For Each objTextBox In objDoc.Shapes If objTextBox.Type = msoTextBox Then objTextBox.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage objTextBox.Left = wdShapeCenter End If Next objTextBox End Sub
To center both pictures and text boxes, you will have to use this one:
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
- Lastly, click “Run” button or hit “F5”.
Address Document Problems
No matter how reluctant we have to admit that Word is not foolproof. Its breaking down can lead to corruption of documents while inheriting a corrupted docx can be heart-broken for us. In order to ease such anxiety, it’s advisable to get hold of a document recovering tool in advance. Then you won’t have to worry about the data loss.
Author Introduction:
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xlsx corruption and pdf repair software products. For more information visit www.datanumen.com
1
This is my first time visit at here and i am genuinely happy to read all at single place.
That’s wonderful!
Can you please include setting Wrap Type to ‘Top and Bottom’ in this macro?
This was very helpful. Thank you!