Solved

Excel VBA save a xlsm file as xlsx

Posted on 2012-03-15
5
10,443 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 500 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

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

729 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