Sub Test_Run()
MkDir "C:\ST\temp\AM"
End Sub
I am trying to create a new folder (AM) in an already existing directory which is C:\ST\temp. But it's causing error showing message: Argument not optional
Sub Test_Run()
MkDir "C:\ST\temp\AM"
End Sub
I am trying to create a new folder (AM) in an already existing directory which is C:\ST\temp. But it's causing error showing message: Argument not optional
Your MkDir function is expecting two arguments and you are only sending one.
Instead of calling
MkDir "C:\ST\temp\AM"
Change it to:
MkDir "C:\ST\temp", "AM"
and it should work.
Function MkDir(strDir As String, strPath As String)
Dim FSO As New FileSystemObject
Dim path As String
path = strPath & strDir
If Not FSO.FolderExists(path) Then
FSO.CreateFolder path
End If
End Function