Link to home
Start Free TrialLog in
Avatar of Tocogroup
TocogroupFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Phillip Burton
Phillip Burton

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Avatar of Tocogroup

ASKER

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