ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code OK in XL2003 but Run-time error '1004' in xl2007 (https://www.excelbanter.com/excel-programming/431433-code-ok-xl2003-but-run-time-error-1004-xl2007.html)

Ken Johnson

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


All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com