How to write VBA code to make backup copy in another folder when s
I have created a shared bank book namely HSBC in J drive and when I save this
file, I would like to make a backup copy in C drive namely 'Backup HSBC', but I don't know exactly how to write VBA code. Should I use the macro function or the Visual Basic Editor under Tools?? Please teach me how to write the macro or VBA code!! I've tried the following but won't work: Sub HSBC (ByValSaveASUI As Boolean, Cancel As Boolean) Application.DisplayAlerts = False ActiveWorkbook.SaveCopyAs "C:\Backup HSBC.xls" & ActiveWorkbook.Name ActiveWorkbook.Save Application.DisplayAlerts = True End Sub What have I done wrong?? please advice!! |
How to write VBA code to make backup copy in another folder when s
Try using the Tools Macros RecordNewMacro feature and go through all the
steps manually to save the file where you want. This will create a macro for you. Post back if you run in to problems. Vaya con Dios, Chuck, CABGx3 "MCC Wong" wrote: I have created a shared bank book namely HSBC in J drive and when I save this file, I would like to make a backup copy in C drive namely 'Backup HSBC', but I don't know exactly how to write VBA code. Should I use the macro function or the Visual Basic Editor under Tools?? Please teach me how to write the macro or VBA code!! I've tried the following but won't work: Sub HSBC (ByValSaveASUI As Boolean, Cancel As Boolean) Application.DisplayAlerts = False ActiveWorkbook.SaveCopyAs "C:\Backup HSBC.xls" & ActiveWorkbook.Name ActiveWorkbook.Save Application.DisplayAlerts = True End Sub What have I done wrong?? please advice!! |
All times are GMT +1. The time now is 06:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com