Pictures.Visible question (after adding many pictures, they stop disappearing)

  • Thread starter Thread starter Abe
  • Start date Start date
A

Abe

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?
 
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)
 
Thanks Dave. That's a wierd quirk of Excel.
-Abe

Dave said:
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top