Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
File Exists | Excel Discussion (Misc queries) | |||
File Exists | Excel Programming | |||
Detect if a file is in use or being modified | Excel Programming | |||
the file already exists - do you want to replace the existing file? | Excel Programming | |||
Detect if file is open | Excel Programming |