Solved

Excel VBA : check the existance of a folder in VBA

Posted on 2007-03-28
5
350 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 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

829 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