View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Stevep4 Stevep4 is offline
external usenet poster
 
Posts: 18
Default Help- Insert text if photo file not available

Can I have that message text into the destination cell itself? for example,
if I am calling for 10 photos in total and only 9 exist, the file would show
9 photos. the 10th cell would display "file does not exist"

"CFS" wrote:

Sorry, my previous answer is incomplete. Again:

Sub InsertPicture()
Dim s As Variant
s = "C:\pictures\" & Range("L21").Value & ".jpg"
If Dir(s) = "" Then
MsgBox "File does not exist!"
Else
Range("ah34").Select
ActiveSheet.Pictures.Insert(s).Select
End If
End Sub


--
CFS


"Stevep4" wrote:

I have set up a macro which inserts a picture onto a cell (AH34), based upon
the value of another cell (L21 - which provides the filename).

Dim s As String
s = "C:\pictures\" & Range("L21").Value & ".jpg"
Range("ah34").Select
ActiveSheet.Pictures.Insert(s).Select


My problem is that if the file does not exist, I get an error box "type
mismatch"

I would like the situation that if a file is not available, it enters "photo
not available" into the cell instead

Something like
IF file=true insert phto
IF file=false inserts "Photo not available"


Any ideas?