Macro to check file loading of picture

GoodmanJim

Board Regular
Joined
Aug 24, 2003
Messages
90
I want to check to see if I have valid variable file address for the picture. If valid I want to insert picture on worksheet. If invalid I want to insert a picture from another work sheet.

Dim myPicture As String
Dim pic As Picture
Set r = Selection 'Range("200")
'error check on PicPath
'set pic = ActiveSheet.Pictures.Insert(PicPath) > 0 then GoTo nopic

Set pic = ActiveSheet.Pictures.Insert(PicPath)
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi, Try this:-
Code:
Dim filesys As Object, myfile As String
Set filesys = CreateObject("Scripting.FileSystemObject")
 myfile = ("C:\Documents and Settings\test\My Documents\My Pictures\MyPic.jpg")

If filesys.fileExists(myfile) Then
    ActiveSheet.Pictures.Insert(myfile).Select
End If
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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