Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Does the hyperlink exist?

I have a rake of files where the file name is in a spreadsheet column but the
file extension is not. There are only two possibilities .pdf or .tif.

How do I get the bit marked ** to work??

I can get the filename from the worksheet by a loop

Filename = Worksheets(SheetName).Cells(row_index, column_index).Value

What I want to do then is

vFile = filename & ".PDF"
vPath = "http:\\amsds0004\chelmsford\ECR_metrics\"

'If the file exists with a PDF extension then ...
** If exists vPath + vFile then
With Worksheets(SheetName)
.Hyperlinks.Add .Cells(row_index, column_index), vFile
End With
'Otherwise it must be a TIF extension so ...
Else
vFile = filename & ".TIF"
With Worksheets(SheetName)
.Hyperlinks.Add .Cells(row_index, column_index), vFile
End With
End if


Thanks Paul

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Does the hyperlink exist?

Use the Dir function.

If Dir(vPath & vFile) < "" Then
' file exists
Else
' file does not exist
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"BigPaul" wrote in message
...
I have a rake of files where the file name is in a spreadsheet
column but the
file extension is not. There are only two possibilities .pdf
or .tif.

How do I get the bit marked ** to work??

I can get the filename from the worksheet by a loop

Filename = Worksheets(SheetName).Cells(row_index,
column_index).Value

What I want to do then is

vFile = filename & ".PDF"
vPath = "http:\\amsds0004\chelmsford\ECR_metrics\"

'If the file exists with a PDF extension then ...
** If exists vPath + vFile then
With Worksheets(SheetName)
.Hyperlinks.Add .Cells(row_index, column_index), vFile
End With
'Otherwise it must be a TIF extension so ...
Else
vFile = filename & ".TIF"
With Worksheets(SheetName)
.Hyperlinks.Add .Cells(row_index, column_index), vFile
End With
End if


Thanks Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Does the hyperlink exist?



"Chip Pearson" wrote:

Use the Dir function.

If Dir(vPath & vFile) < "" Then
' file exists
Else
' file does not exist
End If


--
Cordially,
Chip Pearson


Thanks Chip ~ a much better solution than my rather clunky. I'll use your
version.
Paul

With Application.FileSearch
.NewSearch
.LookIn = vPath
.SearchSubFolders = False
.FileName = vFile
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles

FileFound = (.Execute() 0) 'True if found, false if not.
End With
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
looking for a function that hopefully exist formula_hardrocker Excel Worksheet Functions 1 January 5th 10 10:04 AM
Exist or Not. ldiaz Excel Discussion (Misc queries) 3 September 6th 06 09:31 PM
Am I Looking For Something That Doesn't Exist? seanryann Excel Discussion (Misc queries) 11 April 1st 06 06:10 PM
How to Display hyperlink addresses that already exist as links to Michelle New Users to Excel 1 March 20th 06 08:01 PM
does a file exist Arien Excel Discussion (Misc queries) 3 January 3rd 06 01:27 PM


All times are GMT +1. The time now is 02:57 PM.

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"