Solved

Excel VBA: directory exist command

Posted on 2003-12-11
2
1,091 Views
Last Modified: 2007-12-19
what is the command for if a directory exists?

mydir = "C:\test"

if mydir exist then return true

0
Comment
Question by:yws812
  • 2
2 Comments
 
LVL 80

Accepted Solution

by:
byundt earned 50 total points
ID: 9920828
Hi yws812,
Try this function, which returns True if the directory exists, false if not:

Function FolderExists(fname) As Boolean
'   Returns TRUE if the folder exists
Dim x As String, ffname As String
ffname = fname
If Right(fname, 1) <> "\" Then ffname = fname & "\"
x = Dir(ffname)
If x <> "" Then FolderExists = True _
    Else FolderExists = False
End Function

Cheers!

Brad
0
 
LVL 80

Expert Comment

by:byundt
ID: 9921093
yws812,
Thanks for the grade!
Brad
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

747 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

12 Experts available now in Live!

Get 1:1 Help Now