Can't pass string >255 characters to Word document

jhawk

New member
Local time
Today, 17:45
Joined
Oct 30, 2009
Messages
8
Hi everyone,

I'm reposting this to see if I can get some additional help as I've been unsuccessful at resolving this problem.

I've created a form-based application using Access that helps users automatically fill out a Word form. For the most part, everything is working great EXCEPT when I try to pass any string greater 255 characters in length from Access to a Word text field using VBA. If it's shorter than 255 characters, I never have a problem, and the string passes fine. But when greater than that, the string simply doesn't pass.

At the suggestion of another forum member, I tried to have Access write the string to a text file and then get my Word form to read that text file, but I think this may be even more complicated for me to do as I'm really a novice at this.

Has anyone ever come up against this kind of problem? Is there any way around it that doesn't involve creating a text file? I would really appreciate some help.

Thanks,

jhawk
 
No, the string has been parsed together from 2 or more smaller strings, each of which originate from text-type fields.
 
What code are you using to send the text field data to the word file?
 
This is the code that I've been using (with some variations in the names):

Code:
docWord.FormFields("bmkVerification6a").Result = strVerification

where "bmkVerification6a" is the bookmark attached to the text field in the Word document, "docWord" is the Document object, and "strVerification" is the string containing the string to be passed to the Word document.
 
This is the code that I've been using (with some variations in the names):

Code:
docWord.FormFields("bmkVerification6a").Result = strVerification

where "bmkVerification6a" is the bookmark attached to the text field in the Word document, "docWord" is the Document object, and "strVerification" is the string containing the string to be passed to the Word document.
It may be worth doing a debug.print on strVerification to make sure it is holding more than 255 chars.
 
I have, in fact, checked with the Debug.Print function to make sure the string is holding more than 255 characters, and it is.

In the meantime I've figured out how to write the string to a text file and then run a macro in Word from Access to read that text file and write it to the Word text field. It seems to work fine, but does require a bit more code. Nonetheless, I'm still confused about why Access won't pass the string, or why Word won't accept it, whichever it may be. Hopefully somebody out there knows what's going on.
 
This is a feature of Microsoft products (I'm not sure how they think it's a feature). You cannot pass more than 255 bytes out of Access.

I had to put the data I wanted to pass out of Access into a table with a Memo field to hold my text data that was greater than 255 bytes. That worked. I was tempted to use the method you ended up with, too, but I was trying to use mostly built in Access functionality (i.e. SQL) to accomplish the goals of my project.
 

Users who are viewing this thread

Back
Top Bottom