Many thanks for the response. I am writing in VB.net, so tried to replicate your code, using the following:
Private Sub RemoveEmptyFields(ByVal NewDoc)
'Dim formFieldsToRemove As New ArrayList
'Dim DocFormFields As Aspose.Word.FormFields
'Dim FCount As Integer
'DocFormFields = newdoc.Range.FormFields
'FCount = newdoc.Range.FormFields.Count
' For i = 0 To (FCount - 1)
'If DocFormFields.Item(i).Result.Length = 0 Then
' formFieldsToRemove.Add(DocFormFields.Item(i))
' End If
' Next
'For Each DocFormFields In formFieldsToRemove
' If DocFormFields.Item(i).ParentNode Is Nothing Then
'DocFormFields.Item(i).ParentNode.Remove()
'End If
'Next
Dim DocFormFields As Aspose.Word.FormFields
Dim FCount As Integer
DocFormFields = NewDoc.Range.FormFields
FCount = NewDoc.Range.FormFields.Count
For i = 0 To (FCount - 1)
If DocFormFields.Item(i).Result.Length = 0 Then
If DocFormFields.Item(i).ParentNode Is Nothing Then
DocFormFields.Item(i).ParentNode.Remove()
End If
End If
Next
End Sub
I couldnt get the first lot to work, so commented it out (green writing) and used the second bit of code. This runs through fine, but doesnt see any of the relevent parent nodes as being null. I am not sure if it is something I have got wrong in the code or if the template document needs amending. I attach the template document (standard pharm sics.doc) and an example of a filled in document with the blank line in the address (example.doc).
Many thanks
Shellie