ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pictures.Visible question (after adding many pictures, they stop disappearing) (https://www.excelbanter.com/excel-programming/366434-pictures-visible-question-after-adding-many-pictures-they-stop-disappearing.html)

Abe[_4_]

Pictures.Visible question (after adding many pictures, they stop disappearing)
 
I have a worksheet which is filled with a bunch of pictures, and
depending on the layout I have there will need to be up to 500-2,000
pictures.... maybe more.

There are only six 'different' pictures however, most are copies of a
reference picture.

I want to be able to hide all the pictures or show them depending on
the value of a checkbox in a userform. Here is the code I have
(chkQCAoverlay is a check box):

Private Sub chkQCAoverlay_Change()

On Error Resume Next
Worksheets(2).Pictures.Visible = chkQCAoverlay.Value
On Error GoTo 0

End Sub

The 'on error' is there in case there are no pictures on the worksheet.


The code works if I have a few pictures (around 30) but if I have many
more, it stops hiding the pictures. Anyone know what's going on?


Dave Peterson

Pictures.Visible question (after adding many pictures, they stopdisappearing)
 
I've seen other code that works with shapes fail when there were lots of them.

Maybe looping through all the pictures would be better:

dim myPict as picture
for each myPict in worksheets(2).pictures
mypict.visible = chkqcaoverlay.value
next mypict

(watch out for typos--untested)

Abe wrote:

I have a worksheet which is filled with a bunch of pictures, and
depending on the layout I have there will need to be up to 500-2,000
pictures.... maybe more.

There are only six 'different' pictures however, most are copies of a
reference picture.

I want to be able to hide all the pictures or show them depending on
the value of a checkbox in a userform. Here is the code I have
(chkQCAoverlay is a check box):

Private Sub chkQCAoverlay_Change()

On Error Resume Next
Worksheets(2).Pictures.Visible = chkQCAoverlay.Value
On Error GoTo 0

End Sub

The 'on error' is there in case there are no pictures on the worksheet.

The code works if I have a few pictures (around 30) but if I have many
more, it stops hiding the pictures. Anyone know what's going on?


--

Dave Peterson

Abe[_4_]

Pictures.Visible question (after adding many pictures, they stop disappearing)
 
Thanks Dave. That's a wierd quirk of Excel.
-Abe

Dave Peterson wrote:
I've seen other code that works with shapes fail when there were lots of them.

Maybe looping through all the pictures would be better:

dim myPict as picture
for each myPict in worksheets(2).pictures
mypict.visible = chkqcaoverlay.value
next mypict

(watch out for typos--untested)

Abe wrote:

I have a worksheet which is filled with a bunch of pictures, and
depending on the layout I have there will need to be up to 500-2,000
pictures.... maybe more.

There are only six 'different' pictures however, most are copies of a
reference picture.

I want to be able to hide all the pictures or show them depending on
the value of a checkbox in a userform. Here is the code I have
(chkQCAoverlay is a check box):

Private Sub chkQCAoverlay_Change()

On Error Resume Next
Worksheets(2).Pictures.Visible = chkQCAoverlay.Value
On Error GoTo 0

End Sub

The 'on error' is there in case there are no pictures on the worksheet.

The code works if I have a few pictures (around 30) but if I have many
more, it stops hiding the pictures. Anyone know what's going on?


--

Dave Peterson




All times are GMT +1. The time now is 01:13 AM.

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