实际上窗体域时可以无限长的,不过默认情况下赋值超过255个字符会出现错误, 微软给出的解决方案:
Sub WorkAround255Limit()
' Set Text1 form field to a unique string.
ActiveDocument.FormFields("text1").Result = "****"
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
Selection.GoTo What:=wdGoToBookmark, Name:="Text1"
Selection.Collapse
Selection.MoveRight wdCharacter, 1
Selection.TypeText (String(256, "W"))
Selection.GoTo what:=wdGoToBookmark, Name:="Text1"
' Remove unique characters from Text1 form field.
With Selection.Find
.Execute findtext:="*", replacewith:="", replace:=wdReplaceAll
End With
ActiveDocument.Protect Password:="", NoReset:=True, Type:= _
wdAllowOnlyFormFields
End Sub
链接:http://support.microsoft.com/kb/163192/en-us?spid=2530&sid=251