Solved

Excel VBA : check the existance of a folder in VBA

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Word and Excel 2013 - Disabled Items List 3 60
Left trim cells in column A Excel vba 2 29
how to transpose my example data using VBA 9 33
Clear Filter 8 38
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
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!
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 will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

770 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