View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
Steve Steve is offline
external usenet poster
 
Posts: 7
Default How can I programatically change photos in one worksheet

I will now close this because I figured out a work around.

Because the sheet failed when the code "me.pictures.visible = false"
was used here's the work around.

I turned all the photos off that didn't match and then turned on the
one that did. I also added an additional line to turn the company's
logo on.

It works...not perfect but it works. I have no clue why
"me.pictures.visible = false" makes it bomb but I thank you for the
help!!!!

Here's the Code:

Option Explicit

Private Sub Worksheet_Calculate()
Dim oPic As Picture
Application.ScreenUpdating = False
'Me.Pictures.Visible = False
With Range("N7")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic

For Each oPic In Me.Pictures
If oPic.Name < .Text Then
oPic.Visible = False
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic

End With

With Range("A2")
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Top
oPic.Left = .Left
Exit For
End If
Next oPic

End With

End Sub