LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Check File Existence

MANY THANKS

"Norman Jones" wrote:

Hi Catalin,

Try:

'=============
Sub Testit()
Dim blExists As Boolean

blExists = FileExists("C:\MyFolder\", "aBook.xls")
End Sub
'<<=============


---
Regards,
Norman



"Catalin" wrote in message
...
many thanks. it does work, but I've got another question: as the message
box
returns true or false how can I pass this result to a variable?

"Norman Jones" wrote:

Hi Catalin,

Try:
'=============
Public Function FileExists(sPath As String, _
Optional sFName As String) As Boolean
FileExists = Len(Dir(sPath & sFName)) 0
End Function
'<<=============

An example of usage might be:
'=============
Sub TestIt()
MsgBox FileExists("C:\MyFolder\", "aBook.xls")
End Sub
'<<=============


---
Regards,
Norman



"Catalin" wrote in message
...
Hi all. How do I check in VBA Excel the existence of a specified file
in a
specified directory and display its status. Thanks








 
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 for existence CWillis Excel Discussion (Misc queries) 3 May 31st 06 01:20 PM
How do I check for existence of a worksheet? LizzieHW Excel Worksheet Functions 1 July 19th 05 06:22 PM
Test for file existence Joseph[_46_] Excel Programming 1 November 12th 04 08:56 PM
Test for file existence Joseph[_45_] Excel Programming 1 November 12th 04 04:04 PM
Code to check existence No Name Excel Programming 2 November 4th 04 01:50 PM


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