Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Detect if file exists

Hello.

I am developing a spreadsheet that references other spreadsheets that are
produced on a regular basis.

I would like to check that the file exists before referencing one of its
cells. Can anyone let me know how to check for the existance of a file?

Many thanks.


PeterW


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Detect if file exists

Do you mean if it is open in your instance of Excel? If so, just try
something like

On Error Resume Next
Set oWB = Workbooks(filename)
On Error Goto 0
If Not oWB Is Nothing Then
Msgbox "Workbook is open
End If

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"PeterW" wrote in message
...
Hello.

I am developing a spreadsheet that references other spreadsheets that are
produced on a regular basis.

I would like to check that the file exists before referencing one of its
cells. Can anyone let me know how to check for the existance of a file?

Many thanks.


PeterW




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Detect if file exists

Thanks Bob.

I'm afraid no. The spreadsheet will not be open but it may or may not exist
on a server.

It's the test for does it or does it not exist I require.

Regards


PeterW

"Bob Phillips" wrote in message
...
Do you mean if it is open in your instance of Excel? If so, just try
something like

On Error Resume Next
Set oWB = Workbooks(filename)
On Error Goto 0
If Not oWB Is Nothing Then
Msgbox "Workbook is open
End If

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"PeterW" wrote in message
...
Hello.

I am developing a spreadsheet that references other spreadsheets that are
produced on a regular basis.

I would like to check that the file exists before referencing one of its
cells. Can anyone let me know how to check for the existance of a file?

Many thanks.


PeterW






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Detect if file exists

dim teststr as string
teststr = ""
on error resume next
teststr = dir("yourpath\yourfilenamehere")
on error goto 0

if teststr = "" then
'not found
else
'found
end if


is one way.

PeterW wrote:

Thanks Bob.

I'm afraid no. The spreadsheet will not be open but it may or may not exist
on a server.

It's the test for does it or does it not exist I require.

Regards

PeterW

"Bob Phillips" wrote in message
...
Do you mean if it is open in your instance of Excel? If so, just try
something like

On Error Resume Next
Set oWB = Workbooks(filename)
On Error Goto 0
If Not oWB Is Nothing Then
Msgbox "Workbook is open
End If

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"PeterW" wrote in message
...
Hello.

I am developing a spreadsheet that references other spreadsheets that are
produced on a regular basis.

I would like to check that the file exists before referencing one of its
cells. Can anyone let me know how to check for the existance of a file?

Many thanks.


PeterW





--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Detect if file exists

Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(fullFileName) Then
....
EndIf

"PeterW" wrote in message
...
Hello.

I am developing a spreadsheet that references other spreadsheets that are
produced on a regular basis.

I would like to check that the file exists before referencing one of its
cells. Can anyone let me know how to check for the existance of a file?

Many thanks.


PeterW






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Detect if file exists

Thank you all very much for your help

PeterW

"PeterW" wrote in message
...
Hello.

I am developing a spreadsheet that references other spreadsheets that are
produced on a regular basis.

I would like to check that the file exists before referencing one of its
cells. Can anyone let me know how to check for the existance of a file?

Many thanks.


PeterW



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
File Exists Mike McLellan Excel Discussion (Misc queries) 2 May 4th 06 09:20 AM
File Exists Pflugs Excel Programming 2 September 4th 05 07:05 AM
Detect if a file is in use or being modified shawb[_2_] Excel Programming 3 June 28th 05 01:04 PM
the file already exists - do you want to replace the existing file? Paul James[_3_] Excel Programming 4 December 12th 03 02:50 AM
Detect if file is open Chad[_6_] Excel Programming 4 July 9th 03 05:05 AM


All times are GMT +1. The time now is 12:24 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"