Solved

Excel VBA save a xlsm file as xlsx

Posted on 2012-03-15
5
9,288 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

815 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

8 Experts available now in Live!

Get 1:1 Help Now