Form Fields

J

JF Bouthillier

Hi all,

From an Access database, I am calling the line: FormFields
("Text1).Result = String. When the string is more than
255 characters, I get the error "String Too Long 4609".
I discovered that this was a Word error.

Do you have any suggestions?

Thank you very much.
JF
 
S

Steve Lang

Hi JF,

Nice of Microsoft, eh? You can type all the text you want, but can't use
..Results to load it via code... You need to populate it with a short string,
then add your long string, then delete the short string :

Sub WorkAround255Limit(ByVal strLocation As String, ByVal strLongData As
String)

' Set Text1 form field to a unique string.

Selection.FormFields(1).Result = "^^^^"

If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect

Selection.GoTo what:=wdGoToBookmark, Name:=strLocation

Selection.Collapse

Selection.MoveRight wdCharacter, 1

Selection.TypeText strLongData

Selection.GoTo what:=wdGoToBookmark, Name:=strLocation

' Remove unique characters from Text1 form field.

With Selection.Find

.Execute findtext:="^", replacewith:="", Replace:=wdReplaceAll

End With

End Sub

HTH and have a great day!

Steve
 

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