Skip to content

Instantly share code, notes, and snippets.

@hedgejanuary
Last active May 6, 2019 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hedgejanuary/9122c3565626f3c138958df111353f0e to your computer and use it in GitHub Desktop.
Save hedgejanuary/9122c3565626f3c138958df111353f0e to your computer and use it in GitHub Desktop.
Save file as .xlsx format
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim fso As Object
Dim fName As String
Dim fPath As String
Set fso = CreateObject("Scripting.FileSystemObject")
Me.Worksheets(1).Cells("B4").Value = "Updated on " & Format(Now, "dd mmm yyyy")
'セルに表示形式を設定しておくなら日付のデータを入力するだけでいい。
fName = fso.GetBaseName(Me.Name)
fPath = Me.Path
Application.DisplayAlerts = False
Me.SaveAs Filename:=fPath & "\" & Format(Now, "yymmdd") & "_" & fName, FileFormat:=xlWorkbookDefault
Application.DisplayAlerts = True
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment