Solved

Excel VBA save a xlsm file as xlsx

Posted on 2012-03-15
5
8,828 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
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.
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.
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.

758 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

21 Experts available now in Live!

Get 1:1 Help Now