Create directory

  • Thread starter Thread starter Soniya
  • Start date Start date
S

Soniya

Hi,

How can i create a direcory using VBA if it do not exists?

for eg. when i click my command button i want to copy
sheet2,sheet3, sheet4 to c:\BkUp\FileName.. so that if
the direcory exixts it will save the file or create BkUp
directory and save the file ???

TIA
Soniya
 
Here is a backup macro I use which should be of help. It will make the
directory if it doesn't already exist.

Sub Backup() 'kept in personal.xls & assigned to toolbar button
On Error GoTo BackupFile
MkDir CurDir & "\Backup"
BackupFile:
With ActiveWorkbook
MyWB = .Path & "\BACKUP\" & .Name
.SaveCopyAs MyWB
.Save
End With
End Sub
 
Back
Top