FormField String too large

R

rua17

I'm inserting a very large string into a formfield typing:

FormFields("txtdesPrimerApellido").Result = "very large string".

Why is word telling me that the string is too large if I set the MAX LENGTH
of the form field as unlimited?

TIA
 
D

Doug Robbins

There's a limit of 255/6 characters. Here's a way around it:

' Macro created 05/09/98 by Doug Robbins to insert long string into
FormField
'
FillText = "Your long string"
LenFillText = Len(FillText)
FirstBit = Left(FillText, 255)
If LenFillText > 255 Then
SecondBit = Mid(FillText, 256, LenFillText - 255)
ActiveDocument.FormFields("Text1").Result = FirstBit
Selection.GoTo What:=wdGoToBookmark, Name:="Text1"
ActiveDocument.Unprotect
Selection.InsertAfter SecondBit
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
Else
ActiveDocument.FormFields("Text1").Result = FillText
End If


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
W

Word Heretic

G'day "rua17" <[email protected]>,

Unlimited means up to the VBA max of 255. The onscreen range can hold
more, but you have to paste or InsertAfter to get the info in.

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


rua17 reckoned:
 
W

Word Heretic

G'day "Doug Robbins" <[email protected]>,

Shouldnt that be a While loop to deal with strings > 255*2 bytes?

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Doug Robbins reckoned:
 

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