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
Where to add these macros? And how to add?