VBA Error 53 ( file not found) although code looks fine.

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//**
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
for test
Dim Missing

then above the place where the error is occurring, yet you have expected to create data add as an example

Image1.Picture = LoadPicture("D:\School Record\General School Record\Students data and admission record\Picture record\" & Range("j7").Value & ".jpg")
Missing = Image1.Picture
OldVal = Range("j7").Value

to be able to evaluate what is actually returned
 
Upvote 0
Erhandler worked best but when i wanted to repeat this code in same worsheet for three different pictures with three ranges then it did not work.
Mean i need this code with error handler to run three times for three different pictuer objects associated with three diffrenet ranges.........
 
Last edited:
Upvote 0
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//**

If need this code for three different pics and ranges and with error handlers for each of them then how will be the procedure.....plz i need it very much......
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,292
Members
449,149
Latest member
mwdbActuary

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