Pictures runtime error using VBA

G

Guest

I'm using VBA in Excel 2003 to look up pictures based on a table of values,
and then display the picture that corrosponds with the value in the table. I
used the McGimpsey & Associates link that the users on this forum refer to
when someone asks the question about looking up pictures:
http://www.mcgimpsey.com/excel/lookuppics.html
I used the method and it worked like a dream!

I went on programming other things and had to add new/extra pictures to my
existing 'database'. The problem is, now everytime I select the value to
display one of the new pictures, I get a run-time error saying 'Error 13:
Type mismatch'

The old pictures work perfectly fine, but the new ones give me the resulting
error. Can anyone help?

(Here is my code)

Dim i As Integer

Dim oPic As Picture
Me.Pictures.Visible = True
Me.CommandButton1.Visible = True

Do While i <= countInt
With Worksheets("pietersplayground").Range(imageRange).Offset(i *
14, 0)
For Each oPic In Me.Pictures
If oPic.Name = .Text Then
oPic.Visible = True
oPic.Top = .Offset(1, 0).Top
oPic.Left = .Offset(1, 0).Left
Exit For
End If
Next oPic
End With
i = i + 1
Loop
 
M

Mike Fogleman

It sounds like the imageRange is not getting updated for the additional
pictures:
With Worksheets("pietersplayground").Range(imageRange).Offset(i *
14, 0)
You may need to Set imageRange = Range(includes new pix)

Mike F
 
P

pepsinmentos

I do include the new pics in the range :p The problem is the 'type'. For some
reason VBA does not acknowledge the fact that the images are of the type
'Pictures'.
Is there any way to convert images to make them 'Pictures'??
 

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

Top