Thread: sheet backup
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
sunilpatel sunilpatel is offline
external usenet poster
 
Posts: 57
Default sheet backup

Can someone please helpme.

I need to backup a sheet called "RP LOG" as a new workbook named "RPLOG".
I have 3 essential requirements though.

1. new workbook and sheet must be protected
2. row one which contains buttons linked to macros bust not be copied
3. the vba code copied across must be deleted.

my attempt below has 2 problems
One is that eventhough i delete row 1 the entire new row one acts as if the
buttons are still there (cursor turns to a hand and links to a macro which
is not in the new workbook resulting in an error)
My second problem is how do i delete the vba code on the new sheet.


Sub Backup()
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Copy
ActiveWorkbook.SaveAs "C:\RPLOG"
ActiveSheet.Unprotect "OLDPASSWORD"
Application.EnableEvents = False
Rows(1).Delete
Cells.Select
Selection.Locked = True
ActiveSheet.Protect "NEWPASSWORD"
Workbooks("RPLOG.XLS").Save
Workbooks("RPLOG.XLS").Close
End Sub