Declare Function SHCreateDirectoryExA Lib "Shell32" (ByVal hwnd As Long, ByVal pszPath As String, ByVal psa As Long) As Long
Public Sub CreateFolder(path As String)
Dim rc As Long 'rc・・・0:nomal/183:Folder Exist
Long = SHCreateDirectoryExA(&O0, path, &O0)
If rc = 0 Then
Debug.Print(path & "を作成しました。")
ElseIf rc = 183 Then
Debug.Print(path & "は存在します。")
Else
Debug.Print(path & "の作成に失敗しました。")
End If
End Sub
Option Explicit
CreateFolder
Private Sub CreateFolder()
Dim path
' path = "C:\CreTest\a\b\c"
path = InputBox("作成するフォルダを入力してください。",,Replace(WScript.ScriptFullName,WScript.ScriptName,""))
Dim objExcel
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.WindowState = -4140 'min
Dim rc 'rc・・・0:nomal/183:Folder Exist
rc = objExcel.ExecuteExcel4Macro("Call(""Shell32"", ""SHCreateDirectoryExA"",""JJCJ"", 0, """ & path & """, 0)")
If rc = 0 Then
WScript.Echo(path & "を作成しました。")
ElseIf rc = 183 Then
WScript.Echo(path & "は存在します。")
Else
WScript.Echo(path & "の作成に失敗しました。")
End If
objExcel.Visible = True
objExcel.Quit
Set objExcel = Nothing
End Sub