Code OK in XL2003 but Run-time error '1004' in xl2007

K

Ken Johnson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top