View Single Post
 
Old 04-04-2018, 05:12 AM
Cosmo Cosmo is offline Windows Vista Office 2007
Competent Performer
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
How about posting the code that's doing the row deletion? It seems that's the logical place to test the status of oTbl.
Here is the code I'm using, the issue is that if all rows are deleted, the table no longer exists, but the reference to oTable is not 'Nothing'. There are other steps which need to be performed to the table after deleting the rows, but I need to be able to test to see if the table has been deleted so I can skip those steps.
Code:
' Remove empty rows
rowCount = oTbl.Rows.count
columnCount = oTbl.Columns.count
For row = rowCount To 1 Step -1
    delete = True
    For column = 1 To columnCount
        If Not (oTbl.Cell(row, column).Range.Text = Chr(13) & Chr(7)) Then
            delete = False
            Exit For
        End If
    Next column
    If (delete) Then
        ' Remove row
        Call oTbl.Rows(row).delete
    End If
Next row
 
' NOTE: Need to check to see if table still exists here (If all rows were deleted)
If (tableExists(oTbl)) Then   ' Can't test for Nothing - object has been deleted, but is NOT nothing.
    ' Do other processing steps to table...
For now, I am using the 'tableExists' function I originally posted to test for the table, but I'd prefer to use a valid test, not testing for error.
Reply With Quote