Hi
I am using Excel 2003. Thanks to Skip I've been able to save a current workbook as a copy and remove links to a database and ensure that users aren't prompted to restore links.
Now I just need to do one more thing: is there code I can add so the copy will not prompt for saving on closing? Better yet, ensure that the copy can't be saved at all even from the file save or save as menu?
Code to date:
Note also that the line of code:
is supposed to be so that when the user opens the copy they open it up to the first worksheet and the cell F4 but it doesn't work - it does open to the first worksheet as I want but to the bottom of the page so any assistance with that code would also be appreciated.
Thanks.
I am using Excel 2003. Thanks to Skip I've been able to save a current workbook as a copy and remove links to a database and ensure that users aren't prompted to restore links.
Now I just need to do one more thing: is there code I can add so the copy will not prompt for saving on closing? Better yet, ensure that the copy can't be saved at all even from the file save or save as menu?
Code to date:
Code:
Sub copyWorkbook()
Dim ws As Worksheet
Dim NewWB As Workbook
Dim qt As QueryTable
'this keeps the copy from being displayed
Application.ScreenUpdating = False
Sheets(Array("WSA", "WSB", "WSC", "WSD", "WSE", "WSF")).Copy
Set NewWB = ActiveWorkbook
Application.DisplayAlerts = False
Application.CutCopyMode = False
With NewWB.Sheets("WSA")
'unlock ALL cells
With .Cells
.Locked = False
.FormulaHidden = False
End With
'lock these cells
With .Range("F4:M40")
.Locked = True
.FormulaHidden = False
End With
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
With NewWB.Sheets("WSDd")
For Each qt In .QueryTables
qt.Delete
Next
NewWB.Sheets("WSD").Visible = xlVeryHidden
End With
NewWB.Sheets("WSC").Select
NewWB.Sheets("WSB").Select
NewWB.Sheets("WSA").Select
NewWB.Sheets("WSA").Range("F4").Select
NewWB.UpdateLinks = xlUpdateLinksNever
NewWB.SaveCopyAs Filename:="E:\My Documents\MyWorkbook_" & Format(Now(), "YYYYMMDD") & ".xls"
ActiveWindow.Close
Application.ScreenUpdating = True
End Sub
Note also that the line of code:
Code:
NewWB.Sheets("WSA").Range("F4").Select
Thanks.