Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default HOW TO: Check if a picture exists?

I have the followinf code

Set picDB = ws.Pictures("DB_LOGO_1")

but if the worksheet does not contain the logo then I get an error,
therefore how can I check if the picture exists before I try to set picDB to
it?

TIA
KM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default HOW TO: Check if a picture exists?

On Error Resume Next
Set picDB = ws.Pictures("DB_LOGO_1")
If picDB is Nothing Then
'Does Not Exist
End If
On Error Goto 0

Charles

Kevin McCartney wrote:
I have the followinf code

Set picDB = ws.Pictures("DB_LOGO_1")

but if the worksheet does not contain the logo then I get an error,
therefore how can I check if the picture exists before I try to set picDB to
it?

TIA
KM


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default HOW TO: Check if a picture exists?

Thats just cheesy coding

"Die_Another_Day" wrote:

On Error Resume Next
Set picDB = ws.Pictures("DB_LOGO_1")
If picDB is Nothing Then
'Does Not Exist
End If
On Error Goto 0

Charles

Kevin McCartney wrote:
I have the followinf code

Set picDB = ws.Pictures("DB_LOGO_1")

but if the worksheet does not contain the logo then I get an error,
therefore how can I check if the picture exists before I try to set picDB to
it?

TIA
KM



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default HOW TO: Check if a picture exists?

Gee glad to be of help....

anyhow you can also loop through them and test the name of all pictures
but that is not very efficient if you have a lot of pictures.

Sub FindPic()
Dim pic1
For Each pic1 In ws.Pictures
If pic1.Name = "DB_LOGO_1" Then _
Set picDB = pic1
Next

Charles

P.S. What's with all the rude posters lately?
Kevin McCartney wrote:
Thats just cheesy coding

"Die_Another_Day" wrote:

On Error Resume Next
Set picDB = ws.Pictures("DB_LOGO_1")
If picDB is Nothing Then
'Does Not Exist
End If
On Error Goto 0

Charles

Kevin McCartney wrote:
I have the followinf code

Set picDB = ws.Pictures("DB_LOGO_1")

but if the worksheet does not contain the logo then I get an error,
therefore how can I check if the picture exists before I try to set picDB to
it?

TIA
KM




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default HOW TO: Check if a picture exists?

There's nothing with using the information returned from an error. That's
why you are given the chance to examine the error and decide how you wish to
proceed.
What would be your "non-cheesy" solution ?

NickHK

"Kevin McCartney" wrote in
message ...
Thats just cheesy coding

"Die_Another_Day" wrote:

On Error Resume Next
Set picDB = ws.Pictures("DB_LOGO_1")
If picDB is Nothing Then
'Does Not Exist
End If
On Error Goto 0

Charles

Kevin McCartney wrote:
I have the followinf code

Set picDB = ws.Pictures("DB_LOGO_1")

but if the worksheet does not contain the logo then I get an error,
therefore how can I check if the picture exists before I try to set

picDB to
it?

TIA
KM







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default HOW TO: Check if a picture exists?

That should read "There's nothing wrong with....

NickHK

"NickHK" .gbl...
There's nothing with using the information returned from an error. That's
why you are given the chance to examine the error and decide how you wish
to
proceed.
What would be your "non-cheesy" solution ?

NickHK

"Kevin McCartney" wrote in
message ...
Thats just cheesy coding

"Die_Another_Day" wrote:

On Error Resume Next
Set picDB = ws.Pictures("DB_LOGO_1")
If picDB is Nothing Then
'Does Not Exist
End If
On Error Goto 0

Charles

Kevin McCartney wrote:
I have the followinf code

Set picDB = ws.Pictures("DB_LOGO_1")

but if the worksheet does not contain the logo then I get an error,
therefore how can I check if the picture exists before I try to set

picDB to
it?

TIA
KM






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
check if sheet exists mohavv Excel Discussion (Misc queries) 1 November 21st 07 01:58 AM
How to check from VBA if sheet exists? Alen Excel Programming 2 March 2nd 06 12:36 PM
Check if filename exists. Darrin Henshaw Excel Programming 6 May 5th 05 11:59 PM
How to check if the directory exists? ira Excel Programming 2 January 19th 04 01:22 PM
check if sheet exists Ross[_6_] Excel Programming 3 July 25th 03 06:46 PM


All times are GMT +1. The time now is 03:49 PM.

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

About Us

"It's about Microsoft Excel"