![]() |
Pictures runtime error using VBA
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 |
Pictures runtime error using VBA
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 "pepsinmentos" wrote in message ... 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 |
Pictures runtime error using VBA
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'?? "Mike Fogleman" wrote: 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 "pepsinmentos" wrote in message ... 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 |
Pictures runtime error using VBA
I don't know the answer to this one.
Sorry, Mike F "pepsinmentos" wrote in message ... 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'?? "Mike Fogleman" wrote: 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 "pepsinmentos" wrote in message ... 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 |
All times are GMT +1. The time now is 05:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com