connecting users of the CorelDRAW family of products

How to center a word(text) in a box

This post has 11 Replies | 0 Followers

Share  
Page 1 of 1 (12 items) | RSS

learntech Posted: Sat, Oct 23 2010 11:15

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. 

 

 

Top 10 Contributor
Pigeon Forge, TN
Male
TAG - gdgmacros.com

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.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

Visit me at my GDGMacros website anytime!

Join me on Facebook to stay up to date with GDGMacros, Tips and Tricks for VBA Automation in CorelDraw, Discounts, specials, Free code and macros, and more cool sometimes not so relevant posts!

Top 10 Contributor
Virginia USA
Male

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

George

TheSignGuy

Computer i5 Intel 2500K 4.0 mh, 16 gig Ram, SSD Main Drive, 1T WD Black, 1T Segate, 2 gig DDR 5 G Force Video card, Windows 7 Utl. 64 bit, ASRock 4 Extreme Mobo


Top 25 Contributor
Santos, Brazil
Male
CorelDRAWMaster
Top 10 Contributor
Pigeon Forge, TN
Male
TAG - gdgmacros.com

HI Silvo.

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

-John

Visit me at my GDGMacros website anytime!

Join me on Facebook to stay up to date with GDGMacros, Tips and Tricks for VBA Automation in CorelDraw, Discounts, specials, Free code and macros, and more cool sometimes not so relevant posts!

Top 25 Contributor
Santos, Brazil
Male
CorelDRAWMaster

Hi Run....

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

Top 25 Contributor
Southeast Texas, USA
Male

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

Jack

Lately, I have too much month left at the end of the money!

Top 10 Contributor
Pigeon Forge, TN
Male
TAG - gdgmacros.com

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

Visit me at my GDGMacros website anytime!

Join me on Facebook to stay up to date with GDGMacros, Tips and Tricks for VBA Automation in CorelDraw, Discounts, specials, Free code and macros, and more cool sometimes not so relevant posts!

Top 25 Contributor
Southeast Texas, USA
Male

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. 

Jack

Lately, I have too much month left at the end of the money!

Top 10 Contributor
Pigeon Forge, TN
Male
TAG - gdgmacros.com

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

Visit me at my GDGMacros website anytime!

Join me on Facebook to stay up to date with GDGMacros, Tips and Tricks for VBA Automation in CorelDraw, Discounts, specials, Free code and macros, and more cool sometimes not so relevant posts!

Where to add these macros? And how to add?

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. 

 

 

 

Page 1 of 1 (12 items) | RSS
© Corel Corporation. The content herein is in the form of a personal web log ("Blog") or forum posting. As such, the views expressed in this site are those of the participants and do not necessarily reflect the views of Corel Corporation, or its affiliates and their respective officers, directors, employees and agents. Terms and Conditions / User Guidelines.