When you use the Text Tool a text is added inside a frame. The frame is not visible when printing, it is only for internal use I guess. Can I add a color to it so that the text gets a background? I don't mean to color the actual text, I just need to add color to the background of it.
If it is not possible, what would be the best way to achive what I want: a text inside a shape of a certain color?
Draw the shape you want first.
Select the text tool (F8) and hover over the outline of the shape. You will see a little AB.
This way you can type any text withing that container.
Graphic Artist & Pre-Press Tech.www.phoenixgfx.tk
Yes. You can add a color background to your text. Shape your frame over the text and put it a layer down (Select frame and press SHIFT+PAGE DOWN). Add color to frame as you desire (use color palete to change text and/or shape as your preference).
playeru:The frame is not visible when printing
Maybe you are using Paragraph Text mode. Press CRTL+F8 to toggle Paragraph Text/ArtisticText modes.
"An old dog learning new tricks". www.winmultimidia.com.br - CDX5 under: Win 7 Ultimate 32 bits // Intel Core Duo 2 x 4,0 Mb Ram // NVIDIA GeForce 512 Mb // 2 HDs: 300 Gb (master) and 160 Gb (slave).
I do it this way
Cheers Adam
Sub OldVersion()
vb_found = False
Set s1 = Activeselection.Shapes(1)
If s1.Type = cdrGroupShape Then
Set a1 = s1.Shapes(1)
Set b1 = s1.Shapes(2)
If a1.Type = cdrTextShape And b1.Type = cdrRectangleShape Then
Set b1 = s1.Shapes(1)
Set a1 = s1.Shapes(2)
End If
If b1.Type = cdrTextShape And a1.Type = cdrRectangleShape Then
vb_found = True
Set vo_textshape = b1
s1.Ungroup
a1.Delete
If vb_found = False Then
If s1.Type = cdrTextShape Then
Set vo_textshape = ActiveShape
If vo_textshape Is Nothing = False Then
Set vo_background = vo_textshape.Layer.CreateRectangle2(vo_textshape.LeftX, vo_textshape.BottomY, vo_textshape.SizeWidth, vo_textshape.SizeHeight)
vo_background.OrderBackOf vo_textshape
vo_background.Fill.UniformColor.RGBAssign 255, 255, 0 'Green Change as you so wish
vo_textshape.CreateSelection
vo_background.AddToSelection
vo_background.Outline.SetNoOutline
ActiveSelection.Group
End Sub
I copied/pasted the macro but don't see it anywhere when I hit run. Does it work with X4?
Sorry about that Activeshape should refer to activeselection ... anyway try this updated version.
I have tested it... on X5 (not x4) just create a textshape with some text ... select the textshape and run S_Main_AddBackground2TextShape
vv_margins(6) = 3 works the best in most circumstances as it operates on the % minimum of sizeheight /sizewidth
Cheers
Adam
Sub S_Main_AddBack2TextShape()'Adds a background to a text shape Dim vsh_shape As Shape Dim vc_color As Color Dim vv_margins(6), vi_count As Integer Dim vb_check, vb_nestd As Boolean vv_margins(1) = 20 'left mm or % vv_margins(2) = 20 'top mm or % vv_margins(3) = 20 'right mm or % vv_margins(4) = 20 'bottom mm or % vv_margins(5) = 20 'corner radius mm or % vv_margins(6) = 3 'This sets the type of margin: 1 for mm; 2 for %; 3 for % based on minimum size Set vc_color = CreateRGBColor(255, 255, 0) If ActiveSelection.Shapes.Count = 1 Then Set vsh_shape = ActiveShape vb_check = False If vsh_shape.Type = cdrTextShape Then If vsh_shape.ParentGroup Is Nothing = False Then If vsh_shape.Parent.Count = 2 Then Set vsh_a1 = vsh_shape.Parent.Item(1) Set vsh_b1 = vsh_shape.Parent.Item(2) vb_nested = False 'Am I editing the text within a background already present If vsh_a1.Type = cdrTextShape And vsh_b1.Type = cdrRectangleShape Then vb_nested = True End If If vsh_b1.Type = cdrTextShape And vsh_a1.Type = cdrRectangleShape Then vb_nested = True End If If vb_nested = True Then Set vsh_shape = vsh_shape.ParentGroup vsh_shape.CreateSelection End If End If End If End If If vsh_shape.Type = cdrTextShape Then vb_check = True If vsh_shape.Type = cdrGroupShape Then If vsh_shape.Shapes.Count = 2 Then Set vsh_a1 = vsh_shape.Shapes(1) 'Do I already have a background Set vsh_b1 = vsh_shape.Shapes(2) If vsh_a1.Type = cdrTextShape And vsh_b1.Type = cdrRectangleShape Then vb_check = True If vsh_b1.Type = cdrTextShape And vsh_a1.Type = cdrRectangleShape Then vb_check = True Set vsh_a1 = Nothing Set vsh_b1 = Nothing End If End If If vb_check = True Then Call S_Called_AddBackground2TextShape(vsh_shape, vc_color, vv_margins) Set vsh_shape = Nothing Set vc_color = Nothing Else MsgBox "Please select an appropriate shape", vbOKOnly End If End IfEnd SubSub S_Called_AddBackground2TextShape(Optional vsh_shape As Shape, Optional vc_color As Color, Optional vv_margins As Variant)'Adds a background to a text shape'Called by S_Main_AddBackground2TextShape Dim vsh_textshape, vsh_background As Shape Dim vsh_a1, vsh_b1 As Shape Dim vb_found As Boolean Dim vi_units, vi_count As Integer Dim vd_rectangle(5) As Double If IsMissing(vsh_shape) = True Then Set vsh_shape = ActiveShape End If If IsMissing(vc_color) Then Set vc_color = CreateRGBColor(255, 255, 0) End If If IsMissing(vv_margins) Then ReDim vv_margins(6) vv_margins(1) = 20 'left mm or % vv_margins(2) = 20 'top mm or % vv_margins(3) = 20 'right mm or % vv_margins(4) = 20 'bottom mm or % vv_margins(5) = 20 'corner radius mm or % vv_margins(6) = 3 'This sets the type of margin: 1 for mm; 2 for %; 3 for % based on minimum size End If vb_found = False If vsh_shape.Type = cdrGroupShape Then If vsh_shape.Shapes.Count = 2 Then Set vsh_a1 = vsh_shape.Shapes(1) Set vsh_b1 = vsh_shape.Shapes(2) If vsh_a1.Type = cdrTextShape And vsh_b1.Type = cdrRectangleShape Then Set vsh_b1 = vsh_shape.Shapes(1) Set vsh_a1 = vsh_shape.Shapes(2) End If If vsh_b1.Type = cdrTextShape And vsh_a1.Type = cdrRectangleShape Then vb_found = True Set vsh_textshape = vsh_b1 vsh_shape.Ungroup vsh_a1.Delete End If Set vsh_a1 = Nothing Set vsh_b1 = Nothing End If End If If vb_found = False Then If vsh_shape.Type = cdrTextShape Then Set vsh_textshape = ActiveShape vb_found = True End If End If If vb_found = True Then If vsh_textshape Is Nothing = False Then vi_units = ActiveDocument.Unit 'Margins in mm If vv_margins(6) = 1 Then ActiveDocument.Unit = cdrMillimeter vd_rectangle(1) = vsh_textshape.LeftX - vv_margins(1) 'margins in mm vd_rectangle(2) = vsh_textshape.BottomY - vv_margins(4) vd_rectangle(3) = vsh_textshape.SizeWidth + vv_margins(3) + vv_margins(1) vd_rectangle(4) = vsh_textshape.SizeHeight + vv_margins(2) + vv_margins(4) vd_rectangle(5) = vv_margins(5) 'corner radius End If 'Margins in % If vv_margins(6) = 2 Then ActiveDocument.Unit = cdrMillimeter vd_rectangle(1) = vsh_textshape.LeftX - vv_margins(1) / 100 * vsh_textshape.SizeWidth 'margins in % vd_rectangle(2) = vsh_textshape.BottomY - vv_margins(4) / 100 * vsh_textshape.SizeHeight vd_rectangle(3) = vsh_textshape.SizeWidth + (vv_margins(3) + vv_margins(1)) / 100 * vsh_textshape.SizeWidth vd_rectangle(4) = vsh_textshape.SizeHeight + (vv_margins(2) + vv_margins(4)) / 100 * vsh_textshape.SizeHeight If vsh_textshape.SizeHeight < vsh_textshape.SizeWidth Then vd_rectangle(5) = vv_margins(5) / 100 * vsh_textshape.SizeHeight 'corner radius Else vd_rectangle(5) = vv_margins(5) / 100 * vsh_textshape.SizeWidth End If End If 'Margins in % based on the minimum of the height & size If vv_margins(6) = 3 Then ActiveDocument.Unit = cdrMillimeter If vsh_textshape.SizeHeight < vsh_textshape.SizeWidth Then vd_rectangle(1) = vsh_textshape.LeftX - vv_margins(1) / 100 * vsh_textshape.SizeHeight 'margins in % vd_rectangle(2) = vsh_textshape.BottomY - vv_margins(4) / 100 * vsh_textshape.SizeHeight vd_rectangle(3) = vsh_textshape.SizeWidth + (vv_margins(3) + vv_margins(1)) / 100 * vsh_textshape.SizeHeight vd_rectangle(4) = vsh_textshape.SizeHeight + (vv_margins(2) + vv_margins(4)) / 100 * vsh_textshape.SizeHeight vd_rectangle(5) = vv_margins(5) / 100 * vsh_textshape.SizeHeight 'corner radius Else vd_rectangle(1) = vsh_textshape.LeftX - vv_margins(1) / 100 * vsh_textshape.SizeWidth 'margins in % vd_rectangle(2) = vsh_textshape.BottomY - vv_margins(4) / 100 * vsh_textshape.SizeWidth vd_rectangle(3) = vsh_textshape.SizeWidth + (vv_margins(3) + vv_margins(1)) / 100 * vsh_textshape.SizeWidth vd_rectangle(4) = vsh_textshape.SizeHeight + (vv_margins(2) + vv_margins(4)) / 100 * vsh_textshape.SizeWidth vd_rectangle(5) = vv_margins(5) / 100 * vsh_textshape.SizeWidth End If End If 'If the radius is too large there could be an error 'Try to stop this occuring If vd_rectangle(5) > vd_rectangle(4) / 2 Then vd_rectangle(5) = 0 If vd_rectangle(5) > vd_rectangle(3) / 2 Then vd_rectangle(5) = 0 On Error GoTo errorhandler Set vsh_background = vsh_textshape.Layer.CreateRectangle2(vd_rectangle(1), vd_rectangle(2), vd_rectangle(3), vd_rectangle(4), vd_rectangle(5), vd_rectangle(5), vd_rectangle(5), vd_rectangle(5)) On Error GoTo 0 'Continue ActiveDocument.Unit = vi_units vsh_background.OrderBackOf vsh_textshape vsh_background.Fill.ApplyUniformFill vc_color vsh_background.Outline.SetNoOutline vsh_textshape.CreateSelection vsh_background.AddToSelection ActiveSelection.Group 'Optional to group End If End If Set vsh_textshape = Nothing Set vsh_background = Nothing Exit Suberrorhandler: MsgBox "There was an error creating the rectangle. Most probably due to the corner radius size. Also check that the margin type is 1, 2 or 3" Err.ClearEnd Sub
---