?
Solved

Excel VBA: directory exist command

Posted on 2003-12-11
2
Medium Priority
?
1,102 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

765 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