bottom
Great WordTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > WordTips Home > Text Boxes and Frames > Text Boxes > Centering a Text Box

Centering a Text Box

Summary: Different ways you can move a text box to the center of the page. (This tip works with Microsoft Word 95, Word 97, Word 2000, Word 2002, and Word 2003.)

Many people wrote in this week with different ideas on how to center a text box between the margins on a page. For many people, centering is definitely a "hit and miss" affair, as was indicated by the potential solutions. Some even suggested simply converting the text box to a frame, and then centering. (It is much easier to center a frame than a text box.) Such solutions do not, however, satisfy everyone. You may want a very precise centering, and you may not want to give up the versatility offered by text boxes when compared to frames.

There are two ways to center items horizontally: you can either center on the page itself, or you can center between margins. If you are using Word 95 and you want to center a text box on a page (irrespective of the margins), then you can follow these steps:

  1. Create your text box as you normally would.
  2. Make sure the Drawing toolbar is visible.
  3. Select the text box. There should be a set of handles that appear around the text box.
  4. Click on the Align Drawing Objects tool on the Drawing toolbar. (It is the third one from the right.) The Align dialog box appears. (Click here to see a related figure.)
  5. Make sure the Page radio button is selected at the bottom of the dialog box.
  6. Select the Center radio button in the Horizontal area of the dialog box.
  7. Click on OK.

Beginning with Word 97 the process is just slightly different, due to large changes made in the Drawing toolbar:

  1. Create your text box as you normally would.
  2. Make sure the Drawing toolbar is visible.
  3. Select the text box. There should be a set of handles that appear around the text box.
  4. Click on the Draw tool on the Drawing toolbar. (This is the left-most tool.) A menu of drawing options appears.
  5. Choose Align or Distribute from the drawing options menu. This displays a submenu with only one option available.
  6. Choose Relative To Page from the submenu.
  7. Click on the Draw tool on the Drawing toolbar again. A menu of drawing options appears.
  8. Choose Align or Distribute from the drawing options menu. This displays a submenu, but this time all the options are available.
  9. Choose any centering options desired from the submenu. To center the text box horizontally, choose Align Center.

Note that these steps produce a text box that is centered on the page, not between the margins. Of course, if you have equal margins on the left and right side of your page, then there is no difference between centering on the page and centering between margins. If your margins are different, however, you may want to center between the margins so that your text box appears centered when compared to the text on the page. If you want to do this, you need to rely on a macro--there is no way to do it using menus within Word.

Unfortunately, creating such a macro in WordBasic is dang near impossible. This is because if you select the text box you want to center and then run the macro, you cannot retrieve the formatting options to determine margin settings. (The FilePageSetup dialog cannot be retrieved when you have a text box selected.) Conversely, if you run the macro without the text box selected (so you can get the page settings), then the macro has no way of knowing which text box you want to center.

VBA is a different story. You can rather easily create a macro that will center the currently selected text box between your margins. The following macro, CenterTextBox, will do just that:

Sub CenterTextBox()
    Dim MyPageWidth As Single
    Dim MyLeftMargin As Single
    Dim MyRightMargin As Single
    Dim MyGutter As Single
    Dim MyTextArea As Single
    Dim MyGraphicWidth As Single
    Dim DistanceFromLeftMargin As Single

    MyPageWidth = ActiveDocument.PageSetup.PageWidth
    MyLeftMargin = ActiveDocument.PageSetup.LeftMargin
    MyRightMargin = ActiveDocument.PageSetup.RightMargin
    MyGutter = ActiveDocument.PageSetup.Gutter
    MyTextArea = MyPageWidth - MyLeftMargin - MyRightMargin - Gutter

    ' Get width of text box itself
    MyGraphicWidth = Selection.ShapeRange.Width

    ' Calculate distance from left margin
    DistanceFromLeftMargin = (MyTextArea - MyGraphicWidth) / 2

    ' Make the settings necessary
    Selection.ShapeRange.RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
    Selection.ShapeRange.Left = DistanceFromLeftMargin
End Sub

Tip #1056 applies to Microsoft Word versions: 95 | 97 | 2000 | 2002 | 2003


Tremendous Table Tips! We often take tables for granted, but Word includes some very powerful ways you can present your tabular data. Discover how to make your tables better, easier to understand, and more effective.
 
Check out WordTips: Terrific Tables today!

Helpful Links

Ask a Word Question
Make a Comment

Tips.Net Home
Tips.Net Store

WordTips FAQ
WordTips Premium

Learn Access Now

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

 

Great Info!

Get tips like this every week in WordTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)