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 said: 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.Add ActiveSelection.Group sr(1).GetBoundingBox x, y, w, h 'adjust this property ####################################### dLeeway = 1 'distance to sides 'adjust this property ####################################### 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:
HI Silvo.
This works for even horizontal distance and vertical distance but I think he wanted an equal distance all the way around.
Hi Run....
It may be that I have misunderstood the question, in any case your macro is very useful. Tks.