String Length Limit in Form Fields??

J

JP

I have an Access 2000 application that I'm using to enter data in text Form
Fields in various Word 2000 documents. The code I'm using in Access is
similar to this:

Dim wordApp As Word.Application
Dim wordDoc As Word.Document
Set wordApp = CreateObject("Word.Application")
Set wordDoc = wordApp.Documents.Open(vDocname,False, True, False, , , True,
, , , , False)
wordDoc.FormFields("FF1").Result = vData1
wordDoc.FormFields("FF2").Result = vData2, etc.

where vData1 and vData2 are data elements coming from the database.

The strings to be put into the Word documents are long strings of text.
When the string is longer than 255 characters, I get Run-time error 4609
(String too long). Is there a limit on passing text through automation? Is
there any way around it?

I want to use FormFields (rather than bookmarks) because the client wants
the Word documents protected to prevent them from being changed by users --
and use of bookmarks would require me to unprotect the form, insert the
text, and then re-protect the form (thus creating the possibility of a
failure that will leave the form unprotected).

Thanks in advance.
 
C

Cindy M -WordMVP-

Hi Jp,
The strings to be put into the Word documents are long strings of text.
When the string is longer than 255 characters, I get Run-time error 4609
(String too long). Is there a limit on passing text through automation? Is
there any way around it?
Your observation is correct, and I think if you search the Knowledge Base on
microsoft.com you'll find an article on the subject, with a workaround. As I
recall, the workaround is basically to unprotect, insert the data into
the bookmark range (a formfield is also a bookmark), then reprotect.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
C

Cindy M -WordMVP-

Hi Jp,
Not what I wanted to hear ...
Mmmm, you may have misunderstood my summary of the
solution. You still use formfields, and the user still gets
a protected file, once automation has finished. The
document just needs to be unprotected for that short amount
of time...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
J

JP

Cindy,

Thanks -- I did understand. I just did not want to be executing code that
unprotects the document, even if only briefly. The client is paranoid about
users making unauthorized changes to the document and would have preferred a
solution that does not involve unprotecting the document at all.

Nonetheless, I've implemented your solution and it does work beautifully.

Thanks again.
 

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