Backup file in folder

  • Thread starter Thread starter shital
  • Start date Start date
S

shital

Is there any macro when i run it will take a backup of
my excel file in c:\mydata folder.

Thanks in Advance.

Shital
 
Shital,

Try something like

ThisWorkbook.SaveCopyAs filename:="C:\mydata\" & Thisworkbook.Name


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
Here is a macro I use to backup to the active folder. Modify to suit.

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
 
Shital,

See the code below. This will save the backup with a date/time
appended to the name, to allow multiple backups.

HTH,
Bernie
MS Excel MVP

Sub BUandSave()
'Saves the current file to "mydata" backup folder and its own folder
Application.DisplayAlerts = False

ActiveWorkbook.SaveCopyAs FileName:="C:\mydata \" & _
Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) &
_
" BU " & Format(Now, " yyyy-mm-dd hh-mm") & ".xls"
ActiveWorkbook.Save

Application.DisplayAlerts = True

End Sub
 
Shital

Sub BUandSave2()
'Saves the current file to a backup folder and the default folder if desired
'Note that any previous backup is overwritten

Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAs FileName:="C:\mydata\" & _
ActiveWorkbook.Name

''ActiveWorkbook.Save''add this line if you want to save to default folder
also

Application.DisplayAlerts = True

End Sub

Gord Dibben XL2002
 
Back
Top