?
Solved

Create a Folder at specified drive location using VBA through Execl

Posted on 2011-02-22
3
Medium Priority
?
371 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:srikanthv2322
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Expert Comment

by:StephenJR
ID: 34951889
MkDir "C:\QTP\"
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 2000 total points
ID: 34951931
Try the following
dim fso as object

set fso = createobject("scripting.filesystemobject")
if not fso.folderexists("C:\QTP\") then
    fso.createfolder("C:\QTP\")
end if

Open in new window

0
 
LVL 10

Expert Comment

by:shahzadbux
ID: 34951937

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

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question