Solved

Excel VBA: directory exist command

Posted on 2003-12-11
2
1,094 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 81

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 81

Expert Comment

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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Spell checking an unbound form in MS Access 2013 9 65
Office 2013 constant OST corruption 22 146
MS Office subscription 11 52
vba - Word save error 11 10
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…
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

821 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