View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Johnson Ken Johnson is offline
external usenet poster
 
Posts: 1,073
Default Code OK in XL2003 but Run-time error '1004' in xl2007

I have a Text Box on Sheet2 assigned to the following macro...

Public Sub CheckTextFit()
Dim K As Long, StrText As String
With Worksheets("Sheet2").Shapes(Application.Caller)
.TextFrame.Characters.Text = ""
StrText = ActiveCell.Value
Do
.TextFrame.Characters(Start:=K * 255 + 1,
Length:=255).Text _
= Mid(StrText, K * 255 + 1, 255)
K = K + 1
Loop While K * 255 < Len(StrText)
End With
End Sub

When I click the text box, in XL2003, the code transfers the contents
of the active cell into the text box in lots of 255 characters . In
XL2007 I get Run-time error '1004' Application-defined or object-
defined error, and this line is highlight...

.TextFrame.Characters(Start:=K * 255 + 1, Length:=255).Text _
= Mid(StrText, K * 255 + 1, 255)

There is no worksheet or workbook protection.

Any ideas?

Ken Johnson