Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Creating a folder

My application creates eight excel spreadsheet "reports".
I have automated naming them, and saving them.
They are saved to a destination folder.
The path is displayed to the user, who may change it if he or she wants to.
I can't assume user skill level. Like, preparing the folder first.
The destination folder may not exist.

What is the cleanest way to "ping" a path, and if the folder isn't there, to create it?
MkDir returns an error if the path exists, but I want to go the other direction.
0
NormaPosy
Asked:
NormaPosy
  • 2
1 Solution
 
GrahamSkanRetiredCommented:
You can use this function to test it.
Function FolderExists(strFolder As String) As Boolean
    If Dir$(strFolder, vbDirectory) <> "" Then
        FolderExists = True
    End If
End Function

Open in new window

0
 
GrahamSkanRetiredCommented:
Are you using a dialogue to allow the user to browse for the folder (and file name)? If so it will be difficult to select a non-existent folder.
0
 
NormaPosyAuthor Commented:
Thank You.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now