Rectangle Size

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i'm adding to a rectangle a text from a range 1 by 1 character like this:

ActiveSheet.Shapes("Rectangle 3").Select
For i = 1 To Len(Range("J17"))
Selection.Characters.Text = Selection.Characters.Text +
Mid(Range("J17").Value, i, 1)
Next

It works, but when i arrives to 255 don't let me fill the rest of the
rectangle.

Anyone Help?
Thanks
 
You can use Characters' Start and Length parameters.

Try this...

Option Explicit
Public Sub test()
Dim lnInitialCharCount As Long, k As Long
With ActiveSheet.Shapes("Rectangle 3")
lnInitialCharCount = .TextFrame.Characters.Count
Do While Len(Range("J17").Value) - (k * 255 - 254) > 0
k = k + 1
..TextFrame.Characters(Start:=lnInitialCharCount + k * 255 - 254, _
Length:=255).Text = Mid(Range("J17").Value, k * 255 - 254, 255)
Loop
End With
End Sub

Ken Johnson
 
Another one:

Option Explicit
Sub testme()
Dim myRect As Shape
Dim myCell As Range
Dim cCtr As Long

With Worksheets("sheet1")
Set myRect = .Shapes("rectangle 3")
Set myCell = .Range("J17")

For cCtr = 1 To Len(myCell.Text) Step 255
With myRect.TextFrame
.Characters(.Characters.Count + 1).Insert _
String:=Mid(myCell.Text, cCtr, 255)
End With
Next cCtr
End With
End Sub
 
Back
Top