Solved

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

Posted on 2014-11-13
4
164 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now