Vba code for getting pictures in excel

abdul43

Board Regular
Joined
Aug 19, 2011
Messages
58
HI Respected All!
here is the code which i am using for getting pics in excel which is working best....
(while special thanks to "Momentman" the great man for helping in preparing this code)

Private Sub Worksheet_Calculate()
Static OldVal As Variant
On Error GoTo errhandler
If Range("j7").Value <> OldVal Then
Image1.Picture = LoadPicture("D:\School Record\General School Record\Students data and admission record\Picture record\" & Range("j7").Value & ".jpg")
OldVal = Range("j7").Value
End If
errhandler:
If Err.Number = 53 Then
Image1.Picture = LoadPicture("")
End If
End Sub


Now i made some amendments for getting some different results i know this forum has unlimited excel experts will any one help me by checking my following code which is giving (error.53) file not found. thanks



Private Sub Worksheet_Calculate()

Static OldVal As Variant


If Range("c11").Value <> OldVal Then
Image2.Picture = LoadPicture("D:\School Record\General School Record\Students data and admission record\Picture record\" & Range("c11").Value & ".jpg")
OldVal = Range("c11").Value

ElseIf Err.Number = 53 Then
Image2.Picture = LoadPicture("D:\School Record\General School Record\Students data and admission record\Picture record\0.jpg")


End If




End Sub
**// 0 is an white blank image//**
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,216,730
Messages
6,132,395
Members
449,725
Latest member
Enero1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top