I am trying create editable field in Word document:
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 contain the name of bookmark where some text had to be inserted,
g_value contain the text that had to be inserted in bookmark g_name.
This code is working, but only if g_value length less then 255 characters. If g_value length more then 255 the macros return error "String too long".
I've tryed insert text like this:
bm.Range.Select
With Selection
.Text = g_value
.Font.Underline = wdUnderlineNone
.Collapse wdCollapseEnd
End With
And this work, but text field are non-editable.
How resolve this issue?