Word form field limit

M

Miriam

Hello,

In my program(vb.net), I am inserting the value into a form field of a Word
template. Code like this:

For Each Fld In WordDoc.ActiveDocument.FormFields
....
fld.Result = value
....
Next

The value is inserted correctly, but it is truncated right after 255
characters. It looks like the form field has a limit up to 255 (even the form
field is set unlimit in the word template). Is there anyone know how to make
FormField unlimit in code?

Thank you in advance

Miriam
 
M

Miriam

Dear Perry,
Thank you very much for your response.
Unfortunately, it didn’t work out with the code in the article. Because I am
programming in VB.NET (Visual Studio 2003) and Word 2000.

The following is my work around and it is working. And also I need to set
the form field enabled so the user can change the value in that form field
later on.
But when I check the Word document, the text in that bookmark form field is
enabled only for the first 255 characters; the rest of the text is
unchangeable. I think that is because the rest(bit) of the text is a part of
the document as a range, not a part of the form field. How can I make the
entire text editable?

Dim Protection As Integer
Dim FirstBit As String
Dim RestBit As String
Dim sValue As String
…
If value.Length > 255 Then
Protection = WordDoc.ActiveDocument.ProtectionType
If Protection <> Word.WdProtectionType.wdNoProtection Then
WordDoc.ActiveDocument.Unprotect(Password:=myPassword)
End If
FirstBit = value.Substring(0, 255)
RestBit = value.Substring(255)
fld.Result = FirstBit
fld.Range.InsertAfter(RestBit)
If Protection <> Word.WdProtectionType.wdNoProtection Then
WordDoc.ActiveDocument.Protect(Type:=CType(Protection,
Word.WdProtectionType), NoReset:=True, Password:= myPassword)
End If
End If


Thank you for your help!

Miriam
 

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