Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
hi how can i close excel files which visible false and runnin background

What I have tried:

Dim xlApp = GetObject(, "Excel.Application")
MsgBox(xlApp.Workbooks.Count)
For i1 As Integer = xlApp.Workbooks.Count To 1 Step -1


    If xlApp.Visible.ToString = False Then xlApp.Workbooks.Item(i1).Close(SaveChanges:=False)

Next
Posted

1 solution

Dim process() As Process = System.Diagnostics.Process.GetProcessesByName("EXCEL")
        For Each p As Process In process
            If CDbl(p.MainWindowHandle) = 0 Then p.Kill()
        Next


i find it :)
 
Share this answer
 
Comments
PIEBALDconsult 12-Nov-21 14:39pm    
Please don't try to answer your own question, just use "Improve question" to add detail.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900