Word的VBA编程中,对窗体域赋值出现4609错误,提示:字符串太长。

实际上窗体域时可以无限长的,不过默认情况下赋值超过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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值