[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Excel VBA save a xlsm file as xlsx

Posted on 2012-03-15
5
Medium Priority
?
11,634 Views
Last Modified: 2012-03-15
I have an xlsm file with a large macro in it. The macro processes the file, and prepares it for sending out via email. I'd like the last step of the macro to save the file as an xlsx, with a name specified via VBA.

When the macro gets up to this line of code:
    ActiveWorkbook.SaveAs "C:\test.xlsm", FileFormat:=51

I get an error:
This extension cannot be used with the selected file type. Change the file extension in the File name text box or select a different file type by changing the Save as Type.

Can anyone help me?
0
Comment
Question by:etech0
[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
  • 2
5 Comments
 
LVL 24

Expert Comment

by:StephenJR
ID: 37724992
Why aren't you using .xlsx?
0
 
LVL 13

Expert Comment

by:Shanan212
ID: 37725002
    ActiveWorkbook.SaveAs Filename:= _
        "C:\test.xlsx",  FileFormat:=xlOpenXMLWorkbook, ReadOnlyRecommended:=False, CreateBackup:=False

Open in new window


try this
0
 
LVL 10

Author Comment

by:etech0
ID: 37725052
Thanks!!!!
Now how do I get rid of this one:?

The following features cannot be saved in a macro free workbook: VB Project....

I know - that's the whole point. Can I tell it not to warn me?
0
 
LVL 13

Accepted Solution

by:
Shanan212 earned 2000 total points
ID: 37725075
Put this before the save
Application.DisplayAlerts = false


and this after
Application.DisplayAlerts = True

Application.DisplayAlerts = false
Application.EnableEvents = False
    ActiveWorkbook.SaveAs Filename:= _
        "C:\test.xlsx",  FileFormat:=xlOpenXMLWorkbook, ReadOnlyRecommended:=False, CreateBackup:=False
Application.EnableEvents = True
Application.DisplayAlerts = True

Open in new window

0
 
LVL 10

Author Closing Comment

by:etech0
ID: 37725413
Thanks! That's a big help...
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

649 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