Saving a file to a specific directory with a macro

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

I've used the following (which I was given here)to save
and name based on a cell content, and it works great.

Sub test()
ActiveWorkbook.SaveAs ThisWorkbook.Sheets("Sheet1").Range
("a1") & ".xls"
End Sub

My new question is,can I specify a directory to store the
file in?
Is it possible to make a directory if one does not exist
based on the name of the file (which is created by cell
content)?
 
Here is a macro I use to make a backup from any directory.
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