<commit_before>Attribute VB_Name = "FileOperation"
'Option Explicit

'File operation
Sub w(Optional fileName As String = "") '{{{
	If fileName = "" Then
		Set wb = ActiveWorkbook
	Else
		Set wb = Workbooks(fileName)
	End If
    wb.Save
End Sub '}}}
Sub wa() '{{{
	For Each wb In Workbooks
		wb.Save
	Next
End Sub '}}}

Sub q(Optional fileName As String = "") '{{{
	If fileName = "" Then
		Set wb = ActiveWorkbook
	Else
		Set wb = Workbooks(fileName)
	End If
	wb.Close

	If Workbooks.count <= 1 Then
		On Error Resume Next
		Workbooks("register.xlsx").Close savechanges:=False
		Application.quit
	End If

End Sub '}}}
Sub q_exclamation() '{{{
	Set atwb = ActiveWorkbook
	atwb.Close savechanges:=False

	If Workbooks.count <= 1 Then
		On Error Resume Next
		Workbooks("registry.xlsx").Close savechanges:=False
		Application.quit
	End If
End Sub '}}}
Sub qa() '{{{
	For Each Wb In Workbooks
		Wb.Close
	Next

	If Workbooks.count <= 1 Then
		On Error Resume Next
		Workbooks("registry.xlsx").Close savechanges:=False
		Application.quit
	End If
End Sub '}}}
Sub qa_exclamation() '{{{
    For Each Wb In Workbooks
        Wb.Close savechanges:=False
    Next
        If Workbooks.count = 0 Then
                Application.quit
        End If
End Sub '}}}

Sub wq(Optional fileName As String = "") '{{{
	Call w(fileName)
	Call q(fileName)
End Sub '}}}

Sub cos() '{{{
    Set atwb = ActiveWorkbook
    Workbooks.CheckOut (atwb.Path & "\" & atwb.Name)
    atwb.Save
    atwb.CheckIn '鎖܂
    If Workbooks.count = 0 Then
                Application.quit
    End If
End Sub '}}}

Sub co() '{{{
    Set atwb = ActiveWorkbook
    Workbooks.CheckOut (atwb.Path & "\" & atwb.Name)
End Sub '}}}

Function Path() '{{{
    MsgBox ActiveWorkbook.Path
    Dim buf As String
    buf = ActiveWorkbook.Path
    With New MSForms.DataObject
        .SetText buf      'ϐ̒lDataObjectɊi[
        .PutInClipboard   'DataObject̃f[^Nbv{[hɊi[
    End With
End Function '}}}

Function fpath() '{{{
    Dim AWF As String
    AWF = ActiveWorkbook.FullName
    With New MSForms.DataObject
        .SetText AWF      'ϐ̒lDataObjectɊi[
        .PutInClipboard   'DataObject̃f[^Nbv{[hɊi[
    End With
    MsgBox AWF
End Function '}}}

Function af() '{{{
        ActiveCell.EntireColumn.Autofit
        ActiveCell.EntireRow.Autofit
End Function '}}}

Sub cd(Optional bookName = "") '{{{
	If bookName = "" Then
		Set book = ActiveWorkbook
	Else
		Set book = Workbooks(bookName)
	End If

	On Error GoTo MyError
		If Left(book.FullName, 2) <> "\\" And Left(book.FullName, 2) <> "ht" Then
			ChDrive book.Path
			ChDir book.Path
		Else
			CreateObject("WScript.Shell").CurrentDirectory = book.Path
		End If

		Debug.Print "moved to " & Curdir
		Exit Sub
	MyError:
		MsgBox "failed cd " & "\n" & Err.Description
End Sub '}}}

Sub update() '{{{
	If Not ActiveSheet.AutoFilter Is Nothing Then
		ActiveSheet.AutoFilter.ApplyFilter
	End If
	ActiveSheet.Calculate
End Sub '}}}

Public Function SmartOpenBook(filePath) '{{{
	Dim buf As String, Wb As Workbook

	On Error Goto Myerror
		'݃`FbN
		buf = dir(filePath)
		If buf = "" Then
			MsgBox filePath & vbCrLf & "݂͑܂", vbExclamation
			Exit Function
		End If

		'ubÑ`FbN
		For Each Wb In Workbooks
			If Wb.FullName = filePath Then
				Wb.Activate
				Exit Function
			End If
		Next Wb

		DoEvents
		' Workbooks.Open FileName:=filePath, Notify:=True, AddToMru:=True
		CreateObject("Wscript.Shell").Run filePath, 5

		Exit Function
	Myerror:
		MsgBox Err.Description & vbCrLf & "Alternatively filepath was copied to clipboard"
		With New MSForms.DataObject<commit_msg>The bug when opening books modified.<commit_after>Attribute VB_Name = "FileOperation"
'Option Explicit

'File operation
Sub w(Optional fileName As String = "") '{{{
	If fileName = "" Then
		Set wb = ActiveWorkbook
	Else
		Set wb = Workbooks(fileName)
	End If
    wb.Save
End Sub '}}}
Sub wa() '{{{
	For Each wb In Workbooks
		wb.Save
	Next
End Sub '}}}

Sub q(Optional fileName As String = "") '{{{
	If fileName = "" Then
		Set wb = ActiveWorkbook
	Else
		Set wb = Workbooks(fileName)
	End If
	wb.Close

	If Workbooks.count <= 1 Then
		On Error Resume Next
		Workbooks("register.xlsx").Close savechanges:=False
		Application.quit
	End If

End Sub '}}}
Sub q_exclamation() '{{{
	Set atwb = ActiveWorkbook
	atwb.Close savechanges:=False

	If Workbooks.count <= 1 Then
		On Error Resume Next
		Workbooks("registry.xlsx").Close savechanges:=False
		Application.quit
	End If
End Sub '}}}
Sub qa() '{{{
	For Each Wb In Workbooks
		Wb.Close
	Next

	If Workbooks.count <= 1 Then
		On Error Resume Next
		Workbooks("registry.xlsx").Close savechanges:=False
		Application.quit
	End If
End Sub '}}}
Sub qa_exclamation() '{{{
    For Each Wb In Workbooks
        Wb.Close savechanges:=False
    Next
        If Workbooks.count = 0 Then
                Application.quit
        End If
End Sub '}}}

Sub wq(Optional fileName As String = "") '{{{
	Call w(fileName)
	Call q(fileName)
End Sub '}}}

Sub cos() '{{{
    Set atwb = ActiveWorkbook
    Workbooks.CheckOut (atwb.Path & "\" & atwb.Name)
    atwb.Save
    atwb.CheckIn '鎖܂
    If Workbooks.count = 0 Then
                Application.quit
    End If
End Sub '}}}

Sub co() '{{{
    Set atwb = ActiveWorkbook
    Workbooks.CheckOut (atwb.Path & "\" & atwb.Name)
End Sub '}}}

Function Path() '{{{
    MsgBox ActiveWorkbook.Path
    Dim buf As String
    buf = ActiveWorkbook.Path
    With New MSForms.DataObject
        .SetText buf      'ϐ̒lDataObjectɊi[
        .PutInClipboard   'DataObject̃f[^Nbv{[hɊi[
    End With
End Function '}}}

Function fpath() '{{{
    Dim AWF As String
    AWF = ActiveWorkbook.FullName
    With New MSForms.DataObject
        .SetText AWF      'ϐ̒lDataObjectɊi[
        .PutInClipboard   'DataObject̃f[^Nbv{[hɊi[
    End With
    MsgBox AWF
End Function '}}}

Function af() '{{{
        ActiveCell.EntireColumn.Autofit
        ActiveCell.EntireRow.Autofit
End Function '}}}

Sub cd(Optional bookName = "") '{{{
	If bookName = "" Then
		Set book = ActiveWorkbook
	Else
		Set book = Workbooks(bookName)
	End If

	On Error GoTo MyError
		If Left(book.FullName, 2) <> "\\" And Left(book.FullName, 2) <> "ht" Then
			ChDrive book.Path
			ChDir book.Path
		Else
			CreateObject("WScript.Shell").CurrentDirectory = book.Path
		End If

		Debug.Print "moved to " & Curdir
		Exit Sub
	MyError:
		MsgBox "failed cd " & "\n" & Err.Description
End Sub '}}}

Sub update() '{{{
	If Not ActiveSheet.AutoFilter Is Nothing Then
		ActiveSheet.AutoFilter.ApplyFilter
	End If
	ActiveSheet.Calculate
End Sub '}}}

Public Function SmartOpenBook(filePath) '{{{
	Dim buf As String, Wb As Workbook

	On Error Goto Myerror
		'݃`FbN
		buf = dir(filePath)
		If buf = "" Then
			MsgBox filePath & vbCrLf & "݂͑܂", vbExclamation
			Exit Function
		End If

		'ubÑ`FbN
		For Each Wb In Workbooks
			If Wb.FullName = filePath Then
				Wb.Activate
				Exit Function
			End If
		Next Wb

		DoEvents
		' Workbooks.Open FileName:=filePath, Notify:=True, AddToMru:=True
		CreateObject("Wscript.Shell").Run Chr(34) & filePath & Chr(34), 5

		Exit Function
	Myerror:
		MsgBox Err.Description & vbCrLf & "Alternatively filepath was copied to clipboard"
		With New MSForms.DataObject
{'fraction_non_alphanumeric': 0.1121013786380727, 'fraction_numerical': 0.002785127419579446, 'mean_word_length': 3.106346483704974, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7221564', 'n_tokens_mistral': 2721, 'n_tokens_neox': 2510, 'n_words': 726}