Hi,
I have a word document (.doc) that has lot of bookmarks on it. On the first half of the document (Pls see attached - the line below ‘Advance Account PY Regular Employer’) if there is no value in the bookmark, I need to delete the empty rows. Same thing with the rows below ‘#0097 TRSL PY Regular Employer’.
This is the code I am using to try to delete the rows.
Dim bAllDeleted As Boolean = False
While bAllDeleted = False
bAllDeleted = True
If tables(0).Rows.Count <> 0 Then
For Each Row As Tables.Row In tables(0).Rows
While String.IsNullOrEmpty(Row.ToTxt.Trim())
Row.Remove()
bAllDeleted = False
End While
Next
End If
End While
doc.Save("C:\Rads\JournalEntryReviewProcess\" + "JETemplate27.doc", SaveFormat.Doc)
But after deleting one blank row, I get an error: “Cannot remove Because there is no parent”. What do I need to add to fix the issue, and also delete ALL the blank rows in the table (just the table 1).