Select shape leading to Out of memory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using excel 2000

i use the following code to delete all the shape in a document

newBook.Worksheets(nameofsheet).Select
newBook.Worksheets(nameofsheet).Shapes.SelectAll
Selection.ShapeRange.Delete

It works fine with most document
but in two cases, there is an out of memory error at shapes.selectALL
but i think there is plenty of memory
could anyone tell me what is the cause and how to fix this?
 
Running your code with Comments on the sheet might cause that problem, and
some other types of shapes. Try -

newBook.Worksheets(nameofsheet).DrawingObjects.delete

above shouldn't error even if the DrawingObjects count is zero

Regards,
Peter T
 
One more...

dim ictr as long
for ictr = newBook.Worksheets(nameofsheet).Shapes.count to 1 step -1
newBook.Worksheets(nameofsheet).Shapes.delete
next ictr
 
Thank you for the help
i have used the code suggested by peter to solve the problem

and for Dave Peterson
I have used your apporach at beginning before i use the selectAll merhod
but this will lead to another error in some cases.
 
Back
Top