Solved

Excel VBA : check the existance of a folder in VBA

Posted on 2007-03-28
5
356 Views
Last Modified: 2010-04-13
Hi,

Just would like to know how to check the existance of a certain folder in Excel VBA.  Thanks.

Stanley
0
Comment
Question by:StanleyLMW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 250 total points
ID: 18813533
Function TestFolder(sPath As String) As Boolean       'Returns TRUE if folder exists, FALSE otherwise
TestFolder = Len(Dir(sPath & IIf(Right(sPath, 1) = Application.PathSeparator, "", Application.PathSeparator), vbDirectory)) > 0
End Function
0
 
LVL 23

Expert Comment

by:ahammar
ID: 18813543
Try this:

If Dir("C:\YourPath", vbDirectory) <> "" Then MsgBox "Folder exists"

:-)
ah
0
 
LVL 23

Expert Comment

by:ahammar
ID: 18813545
oops...to late...

0
 

Author Comment

by:StanleyLMW
ID: 18813546
You are really the expert of all experts .... ^.^
0
 
LVL 81

Expert Comment

by:byundt
ID: 18813556
Stanley,
Like a one-trick pony, I'm an expert proficient only in Excel questions, alas.

Thanks for the grade!
Brad
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question