### How to center a word(text) in a box

I want to place a word into a square box and it should be in the centre of the box. How can I center it? I want equal spaces in between the word and the box for all four sides.

#### 11 Replies - Latest Reply

• learntech

I want to place a word into a square box and it should be in the centre of the box. How can I center it? I want equal spaces in between the word and the box for all four sides.

Hi.

Calculating the size of your box is the way. Get the measurement of your text and calculated the needed height and width of the box. Then select both the box and the text and press c, and then e on you keboard to center them horizontally and vertically.

Converting the text to curves before getting measurements may improve accuracy.

Here's a macro that does it for you quickly.

```Sub makeMeABox()

Dim sr As New ShapeRange
Dim x As Double, y As Double, w As Double, h As Double
Dim dLeeway As Double

ActiveDocument.Unit = cdrInch
If ActiveSelection.Shapes.count = 0 Then Exit Sub

sr(1).GetBoundingBox x, y, w, h

dLeeway = 1 'distance to sides

sr.Add ActiveLayer.CreateRectangle2(x - dLeeway, y - dLeeway, w + dLeeway * 2, h + dLeeway * 2)
With sr(2): .OrderBackOne: .Fill.ApplyNoFill: End With
sr.Shapes.All.Group

End Sub

```

-John

• Hello learntech;You can use the “align and distribute” in the Arrange pull down to center a object in a box.

George

• Steps:

• In reply to Silvio Gomes:

HI Silvo.

This works for even horizontal distance and vertical distance but I think he wanted an equal distance all the way around.

-John

• In reply to Sub GDG_John( ):

Hi Run....

It may be that I have misunderstood the question, in any case your macro is very useful. Tks.

[edited by: Silvio Win at 13:21 (GMT -5) on Sat, Oct 23 2010]
• As you can see above, there are many ways. I find the simplest it to select the object or text to be centered and then holding the shift select the to Object in which you wish it centered. Next strike the "c key" to center horizontally and the "e key" to center vertically

[edited by: Jack Ross at 13:35 (GMT -5) on Sat, Oct 23 2010]
• In reply to Silvio Gomes:

Silvio Win

Hi Run....

It may be that I have misunderstood the question, in any case your macro is very useful. Tks.

HI Silvio.

I thought the same thing when I first read also. Then I noticed that c and e wouldn't give equal distance on all 4's. I had just answered this thread with the same question so I figured it would work good in this case too.

I use a similar macro to automatically place a box around an item. It's nice because it makes the margin equal on all four sides.

You can easily adapt it to make the square dark. This is great to show a light color object on a dark background.

-John

• In reply to Sub GDG_John( ):

RunFlaCruiser

Silvio Win

Hi Run....

It may be that I have misunderstood the question, in any case your macro is very useful. Tks.

HI Silvio.

I thought the same thing when I first read also. Then I noticed that c and e wouldn't give equal distance on all 4's. I had just answered this thread with the same question so I figured it would work good in this case too.

I use a similar macro to automatically place a box around an item. It's nice because it makes the margin equal on all four sides.

You can easily adapt it to make the square dark. This is great to show a light color object on a dark background.

-John

Following the question closely John, your solution does not solve  the question either. Nor does mine. The question specifies the object surrounding the text is a square. I think perhaps that the real solution to to modify the text to a square shape. Which could require streching, shrinking and other tools  then using the envelope tool  to place in a square and then centering the text within a square.

[edited by: Jack Ross at 2:49 (GMT -5) on Sun, Oct 24 2010]
• In reply to Jack Ross:

Jack Ross

Following the question closely John, your solution does not solve  the question either.

Ah

Yes, you're right Jack. Could be he wants to stretch the text instead.

-John

• In reply to Sub GDG_John( ):

• learntech

I want to place a word into a square box and it should be in the centre of the box. How can I center it? I want equal spaces in between the word and the box for all four sides.

learntech

I want to place a word into a square box and it should be in the centre of the box. How can I center it? I want equal spaces in between the word and the box for all four sides.