Solved

Create a Folder at specified drive location using VBA through Execl

Posted on 2011-02-22
3
365 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
3 Comments
 
LVL 24

Expert Comment

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

Accepted Solution

by:
Chris Bottomley earned 500 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now