Solved

Excel VBA : check the existance of a folder in VBA

Posted on 2007-03-28
5
342 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
  • 2
  • 2
5 Comments
 
LVL 80

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 80

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now