srikanthv2322
asked on
Create a Folder at specified drive location using VBA through Execl
I want to create a empty folder in a specified drive location using VBA though Excel at click of Command Button
EX:
I want to create a folder name 'QTP' in Drive C
C:\QTP\
Please let me know the code for the above at a click of Command Button
EX:
I want to create a folder name 'QTP' in Drive C
C:\QTP\
Please let me know the code for the above at a click of Command Button
MkDir "C:\QTP\"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sub CreateFolder()
Dim fso
Dim fol As String
fol = "c:\QTP" ' change to match the folder path
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(fol) Then
fso.CreateFolder (fol)
Else
MsgBox fol & " already exists!", vbExclamation, "Folder Exists"
End If
End Sub