Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27355

need to close all Excel before saving...

$
0
0
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:

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

Please add working code. Thank you.

Viewing all articles
Browse latest Browse all 27355

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>