Hello everyone,
Apparently this is a known problem? String too long while renaming formfields.
Background: I have many forms which have been filled out by users, however the form design was shoddy and the fields were not properly bookmarked. I need to rename the fields/bookmarks to enable uploading the field data into an access database. The form fields are all set to unlimited text. However when using the following function, I am getting a string too long error. The fix documented at
http://word.mvps.org/FAQs/MacrosVBA/...mFldResult.htm doesnt work for me. I've attached a sample file with the function below installed in the vba section. Can someone assist me with getting the function working. thanks
Option Explicit
Sub RenameFormFields()
Dim oFrmFlds As FormFields
Dim pIndex As Long
Dim i As Long
Dim j As Long
Dim k As Long
Dim oVar As Variant
pIndex = 0
i = 0
j = 0
k = 0
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
Set oFrmFlds = ActiveDocument.FormFields
For pIndex = 1 To oFrmFlds.Count
oFrmFlds(pIndex).Select
Select Case oFrmFlds(pIndex).Type
Case wdFieldFormTextInput
oVar = oFrmFlds(pIndex).Result
i = i + 1
With Dialogs(wdDialogFormFieldOptions)
.Name = "Text" & i
.Execute
End With
oFrmFlds(pIndex).Result = oVar
Case wdFieldFormCheckBox
oVar = oFrmFlds(pIndex).CheckBox.Value
j = j + 1
With Dialogs(wdDialogFormFieldOptions)
.Name = "Check" & j
.Execute
End With
oFrmFlds(pIndex).CheckBox.Value = oVar
Case wdFieldFormDropDown
oVar = oFrmFlds(pIndex).DropDown.Value
k = k + 1
With Dialogs(wdDialogFormFieldOptions)
.Name = "DropDown" & k
.Execute
End With
On Error Resume Next
oFrmFlds(pIndex).DropDown.Value = oVar
On Error GoTo 0
Case Else
'Do Nothing
End Select
Next pIndex
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
lbl_Exit:
Exit Sub
End Sub