Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default check to see a file is existed

Hi Guys,

How Can I :
1- check to see a file (non excel file) is existed?
2- like I do double click on a file (on windows area) to open it with its
application, how can I do the same thing with VBA?

Thanks in advance


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default check to see a file is existed

To check if a file exists use a function like this:

Function bFileExists(ByVal sFile As String) As Boolean

Dim lAttr As Long

On Error Resume Next
lAttr = GetAttr(sFile)
bFileExists = (Err.Number = 0) And ((lAttr And vbDirectory) = 0)
On Error GoTo 0

End Function


To open a file look at Shell in the VBA help.


RBS


"2007-User" wrote in message
...
Hi Guys,

How Can I :
1- check to see a file (non excel file) is existed?
2- like I do double click on a file (on windows area) to open it with its
application, how can I do the same thing with VBA?

Thanks in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default check to see a file is existed

Thanks,!

"RB Smissaert" wrote in message
...
To check if a file exists use a function like this:

Function bFileExists(ByVal sFile As String) As Boolean

Dim lAttr As Long

On Error Resume Next
lAttr = GetAttr(sFile)
bFileExists = (Err.Number = 0) And ((lAttr And vbDirectory) = 0)
On Error GoTo 0

End Function


To open a file look at Shell in the VBA help.


RBS


"2007-User" wrote in message
...
Hi Guys,

How Can I :
1- check to see a file (non excel file) is existed?
2- like I do double click on a file (on windows area) to open it with its
application, how can I do the same thing with VBA?

Thanks in advance




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
How to check whither a text is existed MFS Excel Worksheet Functions 3 March 8th 09 06:24 PM
code to check file size everytime an Excel file is opened Kaiser[_2_] Excel Programming 2 July 30th 06 05:46 PM
Which function to check any value existed withing a list? Eric Excel Discussion (Misc queries) 1 December 31st 05 12:38 AM
Which function to check any value existed withing a list? Eric Excel Worksheet Functions 1 December 31st 05 12:35 AM
Strange VBA speed issue based on whether overwritten file originally existed or not (?I think?). Excel from Access VBA A C Excel Programming 0 September 13th 05 11:51 PM


All times are GMT +1. The time now is 12:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"