Hi. For now, I would like to close the file test1.xlsx before saving to it.
But in the future, I would like to close ALL Excel before saving. I have tried the following without any success:
Please add working code. Thank you.
But in the future, I would like to close ALL Excel before saving. I have tried the following without any success:
HTML Code:
Dim instances() As Process = Process.GetProcessesByName("EXCEL.EXE")
If (System.IO.File.Exists("C:\test1.xlsx")) Then
MsgBox("The file is already open")
For Each instance As System.Diagnostics.Process In instances
instance.Kill()
Next
Else
MsgBox("The file isn't open")
xlApp.DisplayAlerts = False
xlWorkSheet.SaveAs(xl_save)
End If