How can I Save a workbook in Excel VBA and then save it with a different name ?

Hi All,

In my Excel VBA application I'm trying to :

1. Save the workbook.
2. And then save the same workbook with a different name.

My code looks like this....

   wbOutput.Save
   wbOutput.SaveAs Filename:=strBackupPath, CreateBackup:=False, FileFormat:=xlOpenXMLWorkbook

It saves the workbook under its new name but it doesn't save the original workbook.

Any ideas ?
Thanks
Toco
TocogroupAsked:
Who is Participating?
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
It should do, assuming that wb is the ActiveWorkbook.

1. Are you sure that it is not saving it?
2. Do you have ON ERROR RESUME NEXT, and thereby masking any problems you may have?
0
 
Glen RichmondCustomer Reporting Programmer.Commented:
try putting a application.displayalerts=false to suppress any dialogs that may be invisible in the backgroud.
You probably have an invisible over write alert!

    Application.DisplayAlerts = False

    wbOutput.Save
    wbOutput.SaveAs Filename:=strBackupPath, CreateBackup:=False, FileFormat:=xlOpenXMLWorkbook

     Application.DisplayAlerts = True

Open in new window

0
 
TocogroupAuthor Commented:
Good shout ! It WAS saving it but in another folder. I'd unwittingly opened a copy of the workbook previously.
Thanks for your help
0
 
TocogroupAuthor Commented:
Thanks for your comments Glen. I had already set DisplayAlerts to False.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.