Results 1 to 4 of 4

Thread: Error No 5854 : String Parameter Too Long

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    121

    Error No 5854 : String Parameter Too Long

    Dear Friends,

    I am using FIND & REPLACE feature of Word object in my application.

    The value which I want to replace is coming from database.The problem is sometimes the value fetched from database is too long nad yhe program generates this error

    5854
    String Parameter Too Long

    Following is the Code snippet from my programme
    VB Code:
    1. For Each styRange In oApp.ActiveDocument.StoryRanges
    2.                 With styRange.Find
    3.                           .Text = "<<" & VSFlexGrid1.TextMatrix(0, c) & ">>"
    4.                           .Replacement.Text = TextToReplace
    5.                           .Forward = True
    6.                           .Wrap = wdFindContinue
    7.                           .Execute Replace:=wdReplaceAll
    8.                          
    9.                     End With
    10.                     Next styRange

    I think Replacemnet.Text is not able to hold a larger string.

    Can any one help for this.

    I m waiting for your replies friend.

    Thanks
    -Sachien

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Error No 5854 : String Parameter Too Long

    you are right, on testing the max length for replacement.text is 255

    change you macro to like this

    VB Code:
    1. With Selection.Find
    2.                           .Text = "mytest"
    3.                           .Replacement.Text = ""
    4.                           .Forward = True
    5.                           .Wrap = wdFindContinue
    6.                           .Execute
    7.                          
    8.                     End With
    9.                     Selection = yourstring

    pete

  3. #3
    Member
    Join Date
    Jun 2005
    Posts
    37

    Re: Error No 5854 : String Parameter Too Long

    What do u mean by Selection = yourstring..please explain...

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Error No 5854 : String Parameter Too Long

    yourstring is a variable with the string you want to replace into the selection, there is no limit on the string length here (or if there is i don't know what it is, but much bigger than 255)

    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width