Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-30-2018, 05:44 AM
Cosmo Cosmo is offline Testing for 'Object has been deleted' error Windows Vista Testing for 'Object has been deleted' error Office 2007
Competent Performer
Testing for 'Object has been deleted' error
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default 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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
set row object variable error CLoos Excel Programming 6 03-10-2017 04:48 PM
Testing for 'Object has been deleted' error Run-time error '424': Object required zlodeh Excel Programming 1 02-24-2016 01:58 AM
Testing for 'Object has been deleted' error Run Time Error 424 - Object Required Doug Needham Excel Programming 4 01-12-2015 10:54 PM
Testing for 'Object has been deleted' error 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft