Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro to savecopy as and break links

I am trying to create a macro that will save a copy of a file as an archive,
using the filename and year as eg(06). It then needs to delete all worksheet
links. The workbook contains three sheets called priority , bud, and eval and
these have links to other workbooks that I want to remove for archiving.
I've scoured this message board and gotten so far but i know i'm doing
something wrong and probably not doing it right. I know its also missing
errorr handing. Any help appreciated.

code as follows
Sub createarchive()
CurrentPath = CurDir
ArchivePath = "C:\SMT\archive\plans\"
workbookname = Active.Workbook.Name
mydate = Year(Now)
Fname = ArchivePath + mydate + workbookname



bmessage = "Do you wish to archive this priority and exit?"
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = bmessage
Style = vbYesNo + vbExclamation + vbDefaultButton1 ' Define buttons.
Title = "Archive" ' Define title.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
ActiveWorkbook.Save
Sheets("Priority 1").Select
ActiveWorkbook.SaveAs Filename:=Fname
ActiveSheet.Buttons.Visible = False
ActiveSheet.Unprotect "123"
Sheets("Bud").Select
ActiveSheet.Unprotect "123"
Sheets("Plan Evaluation").Select
ActiveSheet.Buttons.Visible = False
ActiveSheet.Unprotect "123"
ActiveWorkbook.BreakLink Name:="C:\SMT\strat\strat.xls",
Type:=xlExcelLinks
ActiveWorkbook.BreakLink Name:="C:\SMT\plans\yearf\budget\finan.xls",
Type:=xlExcelLinks

Sheets("Priority 1").Select
ActiveSheet.Protect "123"
Sheets("Bud").Select
ActiveSheet.Protect "123"
Sheets("Plan Evaluation").Select

ActiveSheet.Protect "123"
Sheets("Priority 1").Select
ActiveWorkbook.Save
MsgBox "A copy of this Target has been saved for archive purposes"
ActiveWorkbook.Close
Application.Exit

Else ' User chose No.
MsgBox ("Archive ABORTED - no backup made")
Exit Sub
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default macro to savecopy as and break links


ActiveWorkbook.SaveCopyAs " NAME OF FILE " & Format(Now, "dd-mm-yy-hh-mm
") & Application.UserName & ".xls"

"schoolie" wrote:

I am trying to create a macro that will save a copy of a file as an archive,
using the filename and year as eg(06). It then needs to delete all worksheet
links. The workbook contains three sheets called priority , bud, and eval and
these have links to other workbooks that I want to remove for archiving.
I've scoured this message board and gotten so far but i know i'm doing
something wrong and probably not doing it right. I know its also missing
errorr handing. Any help appreciated.

code as follows
Sub createarchive()
CurrentPath = CurDir
ArchivePath = "C:\SMT\archive\plans\"
workbookname = Active.Workbook.Name
mydate = Year(Now)
Fname = ArchivePath + mydate + workbookname



bmessage = "Do you wish to archive this priority and exit?"
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = bmessage
Style = vbYesNo + vbExclamation + vbDefaultButton1 ' Define buttons.
Title = "Archive" ' Define title.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
ActiveWorkbook.Save
Sheets("Priority 1").Select
ActiveWorkbook.SaveAs Filename:=Fname
ActiveSheet.Buttons.Visible = False
ActiveSheet.Unprotect "123"
Sheets("Bud").Select
ActiveSheet.Unprotect "123"
Sheets("Plan Evaluation").Select
ActiveSheet.Buttons.Visible = False
ActiveSheet.Unprotect "123"
ActiveWorkbook.BreakLink Name:="C:\SMT\strat\strat.xls",
Type:=xlExcelLinks
ActiveWorkbook.BreakLink Name:="C:\SMT\plans\yearf\budget\finan.xls",
Type:=xlExcelLinks

Sheets("Priority 1").Select
ActiveSheet.Protect "123"
Sheets("Bud").Select
ActiveSheet.Protect "123"
Sheets("Plan Evaluation").Select

ActiveSheet.Protect "123"
Sheets("Priority 1").Select
ActiveWorkbook.Save
MsgBox "A copy of this Target has been saved for archive purposes"
ActiveWorkbook.Close
Application.Exit

Else ' User chose No.
MsgBox ("Archive ABORTED - no backup made")
Exit Sub
End If
End Sub

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
Can't get Break Links macro to work... from last week (10/6) Steve Excel Worksheet Functions 0 October 13th 09 07:26 PM
Break Links using a macro problem merry_fay Excel Discussion (Misc queries) 0 July 31st 08 12:26 PM
Break Links Sean Excel Discussion (Misc queries) 1 October 25th 06 03:34 PM
Append DateTime to Fiename, saveCopy CLR Excel Programming 2 April 17th 06 03:43 PM
break links peadar Excel Programming 2 March 22nd 05 12:43 AM


All times are GMT +1. The time now is 10:23 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"