Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Public Sub CreateFolder(FolderFullPath As String)
' パスを\区切りで分ける
Dim FolderPaths As Variant ' フォルダ名リスト
FolderPaths = Split(FolderFullPath, "\")
Dim FSO As Scripting.FileSystemObject
Set FSO = New Scripting.FileSystemObject
' フォルダを作成する
Dim FolderPath As Variant ' フォルダ名リストから取り出したフォルダ名
Dim CurPath As String
On Error Goto catch
For Each FolderPath In FolderPaths
' 上位層からのフォルダパスを作る
CurPath = CurPath & Path & "\"
If Not FSO.FolderExists(CurPath) Then FSO.CreateFolder (CurPath)
Exit Sub
MsgBox Err.Source & vbCrLf & Err.Description, vbCritical + vbOKOnly
Error (Err.Number)
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment