Excel Default Saving as .htm Format

blaiaa

New Member
Joined
Nov 2, 2018
Messages
1
I've been running into an issue where after running a macro to generate an excel spreadsheet, when I click on the save icon in this newly generated excel workbook it gets saved as a .htm file, but when I do file->save as, it is appropriately saved in .xlsm format. I'm not entirely sure why there is a discrepancy between the two methods for saving the workbook. I would like to have it be able to save as an .xlsm file regardless of the way that the file is saved. I've tried writing in some vba code to save it as a .xlsm file after the code for the generation of the excel workbook, but it also defaults to .htm format regardless of setting the FileFormat to 52. I've also tried to set my default save format to be .xlsm, but that yields a .htm file when I hit the save icon as well. If it's important to note, this excel workbook is generated and stored into a directory on a network drive. Any help is appreciated!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Welcome to the Board

You could trap the save event:

Code:
' at ThisWorkbook module
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Application.EnableEvents = False
Application.DisplayAlerts = False
Me.SaveAs Me.FullName
MsgBox "Saved as " & Me.FullName
Application.EnableEvents = True
Application.DisplayAlerts = True
Cancel = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,854
Members
449,096
Latest member
Erald

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