Excel Workbooks are not being completely Closed via VB.net

I'm discovering that my Excel spreadsheets that are being created by a VB.net app I've written isn't completely closing them as they should be. I'm struggling to understand why and how to fix this. Here is the code for the portion of the app that creates the workbook, inserts the data and closes the workbook (or it should be). Do you see some commands that I may be missing (they are at the bottom of the code)?

This is definitely a double dot problem. You need to wrap the Excel object and implement the IDisposable interface in the wrapper. You also need to release the each Excel.Object you create. A minima you need the code I'm exposing below.
`

`
Please be forewarned that his approach is not advisable. You might want to use Excel without using Interop, i.e. generating the xls(x) directly without access to Excel. There must be packages available, let me know (I'm still using this and getting more and more problems with it).

I've gone back to working on this with no success. I've done a lot of reading and all offer various ideas. I've also tried your method of closing the instances with no success. Here is my latest updates:

@doncwilson. When I read your top post it was "Excel Workbooks are not being completely Closed via VB.net" and now
"I cannot get these instances of Excel to close after numerous changes and attempts".

So that's different so as a test, do these processes exit/close when your app or if running in Visual Studio (which version?) closes?

Why I ask is in one app that I fielded I had to spawn a copy of my app to do a thing and it would exit when done and that would clean up nicely. Files closing is one thing, a process is another. Sorry that I didn't read that right in your opening post.

@rproffitt, To clarify, because as the app ran I noticed the computer speed degrading. So I opened the task manager and saw many many instances of Excel open (via the "Processes" tab. That's when I knew Excel wasn't completely closing the process. This tool was built in Visual Studio 2015.

If you have ideas, don't hesitate to offer it. I'll try anything to get these processes to shut down.

@Don. I didn't find an answer to my question. That test would have me offer the method I used in another app where I launch workers to do the thing then workers die as they finish. The main app manages how many workers are running. Since we have multicore machines now, this is how I maximized my old app throughput.

@Minimalist, when you say "if others are also using excel , their processes will also be killed.", are you meaning that if the user has other instances of Excel open, those will be killed too? Or do you mean other users on our network will have their instances of Excel killed?

The latter doesn't seem right, but I can see where any instance of excel could be killed if others are open.

I did read through the link earlier today but didn't attempt anything. If it's only going to kill all the Excel processes on my computer, I'm good with that.

Well, I am not on a network so I can't test if all instance of excel are going to be closed. However testing on my machine shows that: if you open more than one instance of excel through vb.net of directly starting excell all instances will be killed. To work out how many instance of excel your machine can see just convert the code I posted to:

If you don't run an instance of excel the counter should be 0 which means also that either your machine is not running excel and no one else is running excel, hence you can kill all instances of excel. If you however not running excel and the counter >0 you need to find a way to only kill your instances of excel and there the process id comes in. Follow the link I posted.

@ Minimalist, I've run your test and found that it didn't find or kill anything on the network. It only killed those Excel applications running on my computer (which is what I anticipated and wanted it to do). Ironically though, I had to run the "Kill" commands twice to get it to clear everything out.

Thanks to everyone who helped out. This was truly great learning - which I greatly appreciate!

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...