#1
|
|||
|
|||
Testing for 'Object has been deleted' error
I have a function which needs to perform several operations on a table "oTb", one of them will remove empty rows "oTbl.rows(row).delete".
If the table is completely empty, all rows are deleted, and the table is deleted. But the object is still valid, and I need to be able to test to see if the table has been deleted. "oTbl is Nothing" evaluates false, even though the table doesn't exist. Is there a test that I can do to determine if the object has been deleted, so I can skip any further processing? I'd rather not try accessing a table property and test for an error, I want to do this a proper way (assuming there is a proper way to do so) Example: this does what I need, but I would prefer not to program by error, I'd rather do a valid test if there is one that I can perform instead Code:
Private Function tableExists(ByRef oTbl As Word.Table) As Boolean On Error Resume Next tableExists = (oTbl.Rows.count > 0) End Function Thanks |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
set row object variable error | CLoos | Excel Programming | 6 | 03-10-2017 04:48 PM |
Run-time error '424': Object required | zlodeh | Excel Programming | 1 | 02-24-2016 01:58 AM |
Run Time Error 424 - Object Required | Doug Needham | Excel Programming | 4 | 01-12-2015 10:54 PM |
Error Message: Could not load an object... | simstem | Word | 1 | 10-06-2012 08:44 PM |
XML parsing & Object variable not set (Error 91) | tinfanide | Excel Programming | 0 | 12-29-2011 08:43 AM |