Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default Help- Insert text if photo file not available

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?


  #2   Report Post  
Posted to microsoft.public.excel.misc
CFS CFS is offline
external usenet poster
 
Posts: 12
Default Help- Insert text if photo file not available

Try:

Dim s As Variant
--
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?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default Help- Insert text if photo file not available

CAn you be a little more specific. What else do I need to put into the code
for it to input something like "Corry no photo" into the cell if the photo
file is not available

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


"CFS" wrote:

Try:

Dim s As Variant
--
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?


  #4   Report Post  
Posted to microsoft.public.excel.misc
CFS CFS is offline
external usenet poster
 
Posts: 12
Default Help- Insert text if photo file not available

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?


  #5   Report Post  
Posted to microsoft.public.excel.misc
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?




  #6   Report Post  
Posted to microsoft.public.excel.misc
CFS CFS is offline
external usenet poster
 
Posts: 12
Default Help- Insert text if photo file not available

Use

Range("ah34") = "File does not exist!"

instead of

MsgBox "File does not exist!"
--
CFS


"Stevep4" wrote:

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?


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default Help- Insert text if photo file not available

This does work if I have basic data in the feeder cell such as "HP97" which
would then become HP97.jpg.

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

It becomes a mess if the information in the feeder cell is #REF. I will
ensure that the information for the feeder cell is either live info or "0".
The "file does not exist" text does not dissapear, but this is not a problem.

Thanks for the help





"CFS" wrote:

Use

Range("ah34") = "File does not exist!"

instead of

MsgBox "File does not exist!"
--
CFS


"Stevep4" wrote:

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?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Photo - help Stevep4 Excel Discussion (Misc queries) 1 January 17th 09 12:59 AM
how do I insert a photo in a protected .xls spreadsheet DarrellBuckley Excel Discussion (Misc queries) 0 May 5th 08 02:00 AM
How to insert a photo in the background for printing. HoganD87 Excel Discussion (Misc queries) 1 August 20th 07 09:24 PM
Insert photo into a protected worksheet Paul Kouri Excel Worksheet Functions 4 April 12th 07 11:15 AM
Insert Photo into a protected worksheet gnolla Excel Worksheet Functions 1 February 5th 06 03:08 AM


All times are GMT +1. The time now is 11:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"