ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select shape leading to Out of memory (https://www.excelbanter.com/excel-programming/333605-select-shape-leading-out-memory.html)

Laguna

Select shape leading to Out of memory
 
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?


NickHK

Select shape leading to Out of memory
 
Laguna,
What does .Shapes.Count equal ?

NickHK

"Laguna" wrote in message
...
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?




Peter T

Select shape leading to Out of memory
 
Running your code with Comments on the sheet might cause that problem, and
some other types of shapes. Try -

newBook.Worksheets(nameofsheet).DrawingObjects.del ete

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

Regards,
Peter T

"Laguna" wrote in message
...
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?




Dave Peterson[_5_]

Select shape leading to Out of memory
 
One more...

dim ictr as long
for ictr = newBook.Worksheets(nameofsheet).Shapes.count to 1 step -1
newBook.Worksheets(nameofsheet).Shapes.delete
next ictr



Laguna wrote:

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?


--

Dave Peterson

Laguna

Select shape leading to Out of memory
 
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.


All times are GMT +1. The time now is 10:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com