Saving a file to a specific directory with a macro

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)?
 
D

Don Guillett

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top