SaveAs method and file format

jkwleisemann

New Member
Joined
May 31, 2016
Messages
19
I'm trying to use Macro templates to create new workbooks, and as a part of that i want to save the template under a new name without the macros enabled. Here's what I'm doing with it:

Code:
    strFileName = Application.GetSaveAsFilename(filefilter:="Excel Files (*.xls), *.xls")
    
    If strFileName <> "" Then ActiveWorkbook.SaveAs Filename:=strFileName, FileFormat:=51, ConflictResolution:=xlUserResolution

The code works, but the problem I'm running into is that, obviously, it doesn't care for trying to save a non-macro file format that has macro code in it, and it generates "extension doesn't match file format" errors when I re-open it.

Any suggestions on how to clear up those two issues? Preferably without having to use the extensibility add-ins to delete all the VBA code?
 
Yes, for projects like these, I usually store my templates and VBA code in separate workbooks.
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,977
Messages
6,175,753
Members
452,667
Latest member
vanessavalentino83

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top