Reputation: 1
I am trying to write some code in Excel which loops through a number of documents and extracts details from FormFields. The documents are all produced from the same template and users can only enter details into the set fields (everything else in the document is locked).
Some of the form fields are optional and so are left blank. But the code extracts a value of " " and inputs that into the cells, which is then causing issues later in the code. I want it to store the value as "".
[I am using Excel 2010]
I have tried the following:
If ActiveDocument.FormFields(1).Range.Text = vbNull Then
If ActiveDocument.FormFields(1).Range.Text = "" Then
If ActiveDocument.FormFields(1).Range.Text = " " Then
and
If ActiveDocument.FormFields(1).TextInput.Default = True Then
And none of them seem to work.
Anyone know how to refer the defaul Default value in a FormField?
Upvotes: 0
Views: 76
Reputation: 18943
Result
property.Option Explicit
Sub demo()
Dim FF As FormField
For Each FF In ActiveDocument.FormFields
If Len(FF.Result) = 0 Then
Debug.Print "Default value is in " & FF.Name
Else
Debug.Print "Users input is in " & FF.Name
End If
Next
End Sub
Microsoft documentation:
Upvotes: 0