Solved

Excel VBA : check the existance of a folder in VBA

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generating a graph via Excel 3 23
Hiding column macro 10 28
Office 2016 Excel Issue 4 25
Mac Excel column treating text as date 2 28
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

932 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

11 Experts available now in Live!

Get 1:1 Help Now