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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Automation Find Object ReplaceWith Limit

Status
Not open for further replies.

zollo9999

Programmer
May 12, 2002
95
AU
Hi

In short: does anyone know if the Word Find Object has a limit on the size (number of characters) that can be used in the ReplaceWith parameter? It seems to fail around 280, and probably has an undocumented 255 character limit.

In Detail:
I've got Office 2003.
My Access Db VBA code uses Automation with Word.

I'm running code that does a kind of mail merge but controlled completedly by the access code.

I have an access vba class that manages an instance of word and opens an existing "template" document (.doc not a .dot). The following code in the class is used to find a place marker and put in the characters that I want....
(Note this code uses objects and methods from the Word Object Model that many may not be familiar with):

Code:
If RequiredDocsList <> vbNullString Then 
 [green]'then RequiredDocsList function has a string value [/green]
 Set objRange = mWordDocument.Content
 [green]'Set range to the whole content of the doc [/green]
 [red]'the next line throws an error [/red]
 objRange.Find.Execute FindText:="RequiredDocsList", Replacewith:=RequiredDocsList, Replace:=wdReplaceOne
End If

When the string function RequiredDocsList has a long list that is around 280 characters long, the code in the class throws error number 0. If the string function RequiredDocsList has a shorter list say around 200 characters, the code works perfectly.

If there is a limit to the number of characters that can be put in the Replacewith parameter, then I could do this:

Add a second place holder, Check for the length, if over 255 chars, split it and then do a second find and replace, if under 255 chars do a normal find and replace and also remove the second place holder.

Any input of course is greatly appreciated :))



Zollo A+ / VBA Developer
[thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top