Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to write VBA code to make backup copy in another folder

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!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default How to write VBA code to make backup copy in another folder

first, a macro that is called from a worksheet cannot havve any parameters.
I don't know if you are calling this macro from a worksheet or another macro.
It looks like (because your have parameters) that it is being called from
another macro

second, you file names is wrong. Do you have a folder called "Backup
HSBC.xls"? You will get an error indicating PATH not found itf you don't
have this folder.

the must be a path seperator "\" between a folder and the file name
from
ActiveWorkbook.SaveCopyAs "C:\Backup HSBC.xls" & ActiveWorkbook.Name
to
ActiveWorkbook.SaveCopyAs "C:\Backup HSBC.xls\" & ActiveWorkbook.Name

"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!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to write VBA code to make backup copy in another folder

Dear Joel,

I'm writing the macro in a worksheet, so what should I do?

MCC

"Joel" wrote:

first, a macro that is called from a worksheet cannot havve any parameters.
I don't know if you are calling this macro from a worksheet or another macro.
It looks like (because your have parameters) that it is being called from
another macro

second, you file names is wrong. Do you have a folder called "Backup
HSBC.xls"? You will get an error indicating PATH not found itf you don't
have this folder.

the must be a path seperator "\" between a folder and the file name
from
ActiveWorkbook.SaveCopyAs "C:\Backup HSBC.xls" & ActiveWorkbook.Name
to
ActiveWorkbook.SaveCopyAs "C:\Backup HSBC.xls\" & ActiveWorkbook.Name

"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!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default How to write VBA code to make backup copy in another folder


See response at one of your other postings.


Gord Dibben MS Excel MVP

On Wed, 16 Jan 2008 04:19:01 -0800, 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!!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Backup another folder Shakeel Excel Discussion (Misc queries) 0 May 26th 08 06:44 AM
How to write VBA code to make backup copy in another folder when s MCC Wong[_2_] Setting up and Configuration of Excel 1 January 16th 08 01:43 PM
save a backup copy in different folder GT Excel Discussion (Misc queries) 3 May 11th 06 07:36 PM
How do i save backup copy in a different folder mekraj Excel Discussion (Misc queries) 3 December 17th 04 08:33 PM
Backup file in folder shital Excel Programming 4 November 3rd 03 04:25 PM


All times are GMT +1. The time now is 11:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"