Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA Worksheet Save w/o Write Protect

Status
Not open for further replies.
Jul 22, 2002
25
US
I have a routine that save one worksheet in my workbook. What it does actually, is makes a "copy" of a worksheet and opens it in a new "window". It then saves that workbook automatically, getting it's name from a cell in the original workbook. Then it switches the window back to the original and closes the copy.

But, if it is already a file, it won't let me write it. Is there a way to automatically save it on top of what is there, or do I delete the original file first?

Here is what I have (in case anybody wanted it anyway)...
'SAVE Data
Dim OrigWBName As String
Dim OrigWSName As String

OrigWBName = ActiveWorkbook.Name
OrigWSName = ActiveSheet.Name

Worksheets("Package").Activate
ActiveSheet.Copy
'ActiveSheet.Name = "ScorpionDump"
ActiveWorkbook.SaveAs FileName:="C:\Junk\" & txtJobNo.Value & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Windows(OrigWBName).Activate
Windows(txtJobNo.Value & ".xls").Close
Worksheets(OrigWSName).Activate

------------
Mr. Pickles
 
Mr. Pickles,

Set the DisplayAlerts propert to false prior to executing the SaveAs command:

Code:
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:="C:\Junk\" & txtJobNo.Value & ".xls", _
    FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=False
Application.DisplayAlerts = True


Regards,
M. Smith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top