[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Excel VBA: directory exist command

Posted on 2003-12-11
2
Medium Priority
?
1,103 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

649 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