Sub X()
' constants
Const ksDot = "."
Const ksDoc = "_doc"
Const ksXLSX = "xlsx"
' declarations
Dim I As Integer, J As Integer, K As Integer, L As Integer
Dim iRows As Integer, iColumns As Integer
Dim sName As String, sFileName As String
Dim sNewName As String, sNewFileName As String
' start
' source workbook
With ActiveWorkbook
sName = .Name
sFileName = .FullName
I = InStr(StrReverse(sName), ksDot)
sNewFileName = Left$(sName, _
Len(sName) - I - 1) & ksDoc & ksDot & ksXLSX
I = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = .Worksheets.Count
End With
' delete
If Dir(sNewFileName, vbNormal) <> "" Then Kill sNewFileName
' add
Workbooks.Add
Application.SheetsInNewWorkbook = I
With ActiveWorkbook
.SaveAs sNewFileName
sNewName = .Name
End With
Workbooks(sName).Activate
' process
With ActiveWorkbook
For I = 1 To .Worksheets.Count
' format
Workbooks(sNewName).Worksheets(I).Cells.NumberFormat = "@"
' name
Workbooks(sNewName).Worksheets(I).Name = .Worksheets(I).Name
' formulas
With .Worksheets(I)
With .UsedRange
iRows = .Rows.Count
iColumns = .Columns.Count
End With
For K = 1 To iRows
For J = 1 To iColumns
Workbooks(sNewName).Worksheets(I).Cells(K, J).Value = .Cells(K, J).Formula
Next J
Next K
End With
Next I
End With
' end
End Sub