PDA

View Full Version : Workbook "Save As" Method - Question



avadhutd2
01-05-2010, 05:34 AM
I have a question about the workbook save as event.

I am working on a workbook OrgWB & I need to save it as ResultWB.xls at C Drive. Further I want to send an email with this workbook (ResultWB.xls) as an attachment.

I had written a code below for this -

' Working on the OrgWB workbook
Dim wb As Workbook
Dim ThisFile As String

ThisFile = "ResultWB"

ActiveWorkbook.SaveAs Filename:= _
"C:\" & ThisFile, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False

' From here I can see file OrgWB now seen as ResultWB.xls.

This creates an excel file ResultWB.xls at C Drive. I had a code ready that sends email with attachment.

But my problem here is, when we do Save As event, the OrgWB is replaced by ResultWB (as expected in save as functionality) & I can no longer work on the OrgWB file.

What can be done to have active workbook just saved at the selected path and at the same time continue working on the original file where we had called the save as event?

Please let me know.

Thanks!

Jan Karel Pieterse
01-05-2010, 06:57 AM
Use the SaveCopyAs method to save a copy of your file.