Limit in "Find -- Replace"

J

Juan

Hi everyone,

I am writing a program that searches for a especific text in a Word document
and replaces it with another text. I am finding that there is a limit in the
length of the text that will replace the original text.

Does anyone know what is this limit, and if there's a way to get over this
limit?

Thanks, from Spain

Juan
 
K

Klaus Linke

Hi Juan,

The "official" limit is 255 characters. Any string longer than that will
give you a "Run-time error '5854': String too long".

But I've noticed crashes with strings that were a bit shorter, so I would be
careful even with strings close to 255 bytes.

As a work-around, you can copy text to the clipboard and use ^c in the
Replacement text, or use "Find" to locate the text and insert your string:

While Selection.Find.Execute
Selection.Text = String(300, "x")
Selection.Collapse (wdCollapseEnd)
Wend

Greetings,
Klaus
 

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

Top