Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple folder creation for a VB simpleton

Status
Not open for further replies.

windsurferm

Automotive
Joined
Jan 11, 2005
Messages
32
Location
GB
We have a generic folder structure which we use for all new projects we start, each new project gets a project number from an excel sheet and currently the individual has to then create the folder, to the same number and then copy the folders from the generic structure into the newly created folder.

I would like to create a button which does all of the above steps with the press of one VB button at the end of the line. However I am not proficient with VB and am looking for some general pointers.
 
Add a reference to the Windows Script Host Model (Tools|References Menu) then you can simply use the FileSystemObject:
Code:
Private Sub cmdMkDir_Click()
mygroup = "C:\Test" 'originals
mynewdir = "c:\test" & CStr(Range("A12").Value)
MkDir mynewdir
Dim w As New FileSystemObject
w.CopyFolder mygroup, mynewdir & "\", True
Set w = Nothing
End Sub

This example picks up the value in Cell A12 and concatenates that value onto 'test' giving the new directory a name such as 'test233' (if A12 contains 233). You will need to add error checking to ensure that the directory doesn't already exist.

Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting

UK steam enthusiasts:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top