Solved

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

Posted on 2014-11-13
4
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
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 on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

733 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