Windows 10 not recognizing file type after file save macro in VBA

captainxcel

New Member
Joined
Jul 28, 2017
Messages
35
Office Version
  1. 2016
Platform
  1. Windows
Hi Folks. I trade stocks. I just created a macro in a "template" file called CIA Trade Blotter Template.xlsm to paste value the trade date from a range that contains "today()" and then save the file (downgrading it to xlsx) with a datestamp appended to the filename [i.e. CIA Trade Blotter 10.25.17]. However, when run the macro and look into the folder where the new file is saved windows identifies the filetype as a ".17" file owing to the date format I prefer to use instead of as a "Microsoft Excel Worksheet". Other than changing the date format or placing the date first in the file naming sequence does anyone know what I'm doing wrong in my code or have a solution to this conundrum?

Sub SaveBlotter()
Range("trade_date").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Dim TradeDate, FileNameRoot
FileNameRoot = "CIA Trade Blotter "
TradeDate = Format((Now), "mm.dd.yy")
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "" & FileNameRoot & TradeDate, FileFormat:=xlOpenXMLWorkbook
End Sub
 
Last edited by a moderator:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
OK - I actually figured this out. The file extension needs to be appended and be consistent with the file format. The following code works:

Sub SaveBlotter()
Range("trade_date").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Dim TradeDate, FileNameRoot
FileNameRoot = "CIA Trade Blotter "
TradeDate = Format((Now), "mm.dd.yy")
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "" & FileNameRoot & TradeDate & ".xlsx", FileFormat:=xlOpenXMLWorkbook
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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