Function NormalizePath(path As String) As String
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(path) Then
NormalizePath = fs.GetAbsolutePathName(path)
Else
NormalizePath = ""
End If
End Function
Sub TestKill()
Dim filePath As String
filePath = "C:\Users\username\Desktop\データ.txt"
filePath = NormalizePath(filePath) ' 正規化して取得
If filePath <> "" Then
Kill filePath
MsgBox "削除成功: " & filePath
Else
MsgBox "削除失敗: パスが見つからない"
End If
End Sub