0
我想Word文檔中創建可編輯的字段:如何在Word-VBA中創建超過255個字符的可編輯字段?
Dim bm As Bookmark
If ActiveDocument.Bookmarks.Exists(g_name) = True Then
Set bm = ActiveDocument.Bookmarks(g_name)
End If
If g_var = "DETAILS" Then
bm.Range.Select
With Selection
.Font.Underline = wdUnderlineNone
.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
Selection.PreviousField.Select
With Selection.FormFields(1)
.Name = g_name
.EntryMacro = ""
.ExitMacro = ""
.Enabled = True
.OwnHelp = False
.HelpText = ""
.OwnStatus = False
.StatusText = ""
With .TextInput
.EditType Type:=wdRegularText, Default:=g_value, Format:=""
End With
End With
End With
End If
ActiveDocument.Protect Password:="mypass", NoReset:=False, Type:=wdAllowOnlyFormFields
g_name包含書籤,其中一些文本必須插入,
g_value包含有在書籤g_name要插入的文本名稱。
此代碼正在工作,但前提是g_value長度小於255個字符。如果g_value長度超過255,則宏返回錯誤「String too long」。
我tryed插入文字是這樣的:
bm.Range.Select
With Selection
.Text = g_value
.Font.Underline = wdUnderlineNone
.Collapse wdCollapseEnd
End With
這方面的工作,但文本字段是不可編輯。
如何解決此問題?