Sub SaveWB()
Dim Folder As String, FileName As String
Dim FilePath As String, TempFilePath As String
Dim Msg As String
Dim DestWB As Workbook
Dim Ans As Integer
Dim WS As Worksheet
Folder = ThisWorkbook.Path
Folder = Trim(Folder)
If Not Right(Folder, 1) = "\" Then
Folder = Folder & "\" 'add backslash if not present
End If
'Make file name
FileName = Trim(ThisWorkbook.Name)
If InStr(FileName, ".") > 0 Then
Do While InStr(FileName, ".") > 0
FileName = Left(FileName, Len(FileName) - 1)
Loop
Else
MsgBox FileName & " invalid" & vbCr & vbCr & FileName
Exit Sub
End If
'New file path
FilePath = Folder & FileName & "_" & Format(Date, "yyyymmdd") & ".xlsx"
'Temporary file path
TempFilePath = Folder & "Tmp$File.xlsm"
'Open temporary workbook.
Application.DisplayAlerts = False
ThisWorkbook.SaveCopyAs TempFilePath
DoEvents 'optional
Set DestWB = Application.Workbooks.Open(FileName:=TempFilePath)
DoEvents 'optional
' Convert everything to values
For Each WS In DestWB.Worksheets
WS.UsedRange.Value = WS.UsedRange.Value
Next WS
'Save new file
DestWB.SaveAs FileName:=FilePath, FileFormat:=xlOpenXMLWorkbook 'see XlFileFormat Enumeration for different formats
DoEvents 'optional
'Clean up
DestWB.Close False
Kill TempFilePath
Application.DisplayAlerts = True
MsgBox "Complete. New file is:" & vbCr & vbCr & FilePath
End Sub