Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Identifying whether an excel file exists

Hello group!

I have a (hopefully) quick query. Can anybody help?

I am writing a procedure and require a function which reads a file
path string and returns true or false depending on whether the file
exists on the user's computer. Does anybody out there know how this
can be achieved?

Thanks in advance.

John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default Identifying whether an excel file exists

Hi JT,

Before you use the below funtion, you have to get a reference to 'Microsoft
Scripting Runtime'

Function CheckFile() As Boolean
Dim mFile As FileSystemObject

Set mFile = New FileSystemObject
CheckFile = mFile.FileExists("C:\test\test.xls")
End Function

In the above function you can type your path or change the function to suit
your requirements.

HTH,
--
Pranav Vaidya
VBA Developer
PN, MH-India
If you think my answer is useful, please rate this post as an ANSWER!!


"JT" wrote:

Hello group!

I have a (hopefully) quick query. Can anybody help?

I am writing a procedure and require a function which reads a file
path string and returns true or false depending on whether the file
exists on the user's computer. Does anybody out there know how this
can be achieved?

Thanks in advance.

John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Identifying whether an excel file exists

JT, try this

len(dir("C:\Test.txt")) 0

Substitute your file for "C:\Test.txt"

--
Charles Chickering

"A good example is twice the value of good advice."


"JT" wrote:

Hello group!

I have a (hopefully) quick query. Can anybody help?

I am writing a procedure and require a function which reads a file
path string and returns true or false depending on whether the file
exists on the user's computer. Does anybody out there know how this
can be achieved?

Thanks in advance.

John

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Identifying whether an excel file exists

Sub test()
If Dir("C:\Data\test.xls") < "" Then
MsgBox "Exist"
Else
MsgBox "Not exist"
End If
End Sub

Just re-cast it as a Boolean function
--
Gary''s Student - gsnu200756


"JT" wrote:

Hello group!

I have a (hopefully) quick query. Can anybody help?

I am writing a procedure and require a function which reads a file
path string and returns true or false depending on whether the file
exists on the user's computer. Does anybody out there know how this
can be achieved?

Thanks in advance.

John

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Identifying whether an excel file exists

Hello JT

Have a look at:

http://www.j-walk.com/ss/excel/tips/tip54.htm

I learned a lot from J. Walkenbachs site!!!

Enjoy!

"JT" schreef in bericht
...
Hello group!

I have a (hopefully) quick query. Can anybody help?

I am writing a procedure and require a function which reads a file
path string and returns true or false depending on whether the file
exists on the user's computer. Does anybody out there know how this
can be achieved?

Thanks in advance.

John





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Identifying whether an excel file exists

Thanks to all of you, that was really helpful.

John Walkenbach wrote the Excel VBA for dummies book and I'm a fan of
his work.
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 but cannot open from Excel [email protected] Excel Programming 4 July 5th 07 07:27 AM
Check if a sheet exists in a file, without opening that file Bogdan Excel Programming 5 March 9th 07 01:46 PM
Macro in Excel using an Array to Delete File in Directory if it Exists Matt[_40_] Excel Programming 3 February 2nd 07 03:16 AM
How to programmatically test whether VBA code exists in an Excel file Paul Martin Excel Programming 7 July 3rd 06 06:25 AM
Personally identifying information in an Excel File Fonz Excel Discussion (Misc queries) 0 June 12th 06 03:21 PM


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