Solved

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

Posted on 2014-11-13
4
168 Views
Last Modified: 2014-11-13
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
0
Comment
Question by:Tocogroup
  • 2
4 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40439639
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
 
LVL 2

Expert Comment

by:Glen Richmond
ID: 40439645
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
 

Author Closing Comment

by:Tocogroup
ID: 40439703
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
 

Author Comment

by:Tocogroup
ID: 40439726
Thanks for your comments Glen. I had already set DisplayAlerts to False.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question