Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Folder exist

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JayM - 11 Jan 2006 20:22 GMT
I know that you can test if a file exists but can you test if a folder
exists.  if so what is the VBA code for it?

Any help appreciated especially examples of code

Thanks
Jonathan West - 11 Jan 2006 20:33 GMT
>I know that you can test if a file exists but can you test if a folder
> exists.  if so what is the VBA code for it?
>
> Any help appreciated especially examples of code
>
> Thanks

Take a look here

http://vbnet.mvps.org/code/fileapi/folderexists.htm

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

Karl E. Peterson - 11 Jan 2006 21:04 GMT
> I know that you can test if a file exists but can you test if a folder
> exists.  if so what is the VBA code for it?

Lots of folks will advise something like this is the simplest way:

  Private Function FolderExists(PathName As String) As Boolean
     If Len(PathName) > 0 Then
        On Error Resume Next
        FolderExists = ((GetAttr(PathName) And vbDirectory) > 0)
        Err.Clear
     End If
  End Function

Signature

Be the 10,000th Signer!
http://classicvb.org

Doug Robbins - Word MVP - 11 Jan 2006 21:50 GMT
You can make use of the fact that you will get a Run time error 76 if the
path does not exist when you use ChDir("path")

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I know that you can test if a file exists but can you test if a folder
> exists.  if so what is the VBA code for it?
>
> Any help appreciated especially examples of code
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.