Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in Macro: String Parameter Too Long

Status
Not open for further replies.

Neenas19

Technical User
Apr 10, 2002
22
US
Hi There,
I have a simple find and replace macro that I would like to run. It does fine up until the text goes above 255 characters. I understand that 255 is the "magic" length. However as I understand it the Dim As STRING should allow MANY more than 255. Correct? Here is my code. Any ideas would be greatly appreciated!
Nina
Public Sub Translate()

Dim n As Integer
Dim xls As Excel.Application
Dim myxls As Excel.Workbook
Dim e As String
Dim K As String

Set xls = CreateObject("Excel.Application")
xls.Workbooks.Open "OUR Network Path"
xls.Visible = True

n = 1

xls.Range("a2").Select
e = ActiveCell.Value
K = ActiveCell.Offset(0, 1)

Do While n < 131
e = xls.ActiveCell.Value
K = xls.ActiveCell.Offset(0, 1)
With Selection.Find
.Text = e
.Replacement.Text = K
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

n = n + 1
xls.ActiveCell.Offset(1, 0).Select

Loop
End Sub
 
What version of Excel ?
Regards
BrianB
** Let us know if you get something that works !
================================
 
Had to knowthe version. XL97 sticks at 255.
Extract from Xl2000 VBA Help :-

String data type
A data type consisting of a sequence of contiguous characters that represent the characters themselves rather than their numeric values. A String can include letters, numbers, spaces, and punctuation. The String data type can store fixed-length strings ranging in length from 0 to approximately 63K characters and dynamic strings ranging in length from 0 to approximately 2 billion characters. The dollar sign ($) type-declaration character represents a String in Visual Basic.
Regards
BrianB
** Let us know if you get something that works !
================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top