Its not clear from your post: have you tried
Set excel = nothing
System.GC.Collect
together?
Have you tried
Set Book = Nothing
also?
Does this help (just reiterating what I said above)
Hi,
I am writing an SSIS package that checks a specific folder for Excel files. Files are dropped into this folder periodically for data updates to our SQL Server. The files are always named differently, as are the worksheets. I have the Data Flow tasks to upload the data to SQLS.
I am writing a Script task in SSIS (VB.NET) to change the Excel file and worksheet names to a standard name (such as Data.xls, DataSheet) for use in the Data Flow tasks.
I have a reference and Imports directive to the Microsoft.Office.Interop.E
I declare a variable of the MS.Office.Interop.Excel type and access the Excel file.
When I'm finished with the object, how do I destroy it? There are still references to Excel.exe in the Task Manager, which are creaeted when executing the task.
I have tried the following to no avail:
excel.dispose()
set excel =nothing '(and old VB 6 technique)
I've also tried calling the
GC.Collect()
GC.WaitForPendingFinalizer
Thanks in advance
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks nmcdermaid. Responding to both posts, the worksheets also are named differently, so I have to get the name of the worksheet (or change it), as well as the file name (also named differently), which is why I chose to use the Excel object model. I have tried your recommendations in the second post, but the Excel.exe process is stil running.
I agree that enumerating the files via the ForEach task would work, if the worksheets had the same name. Unfortunately, the user that creates the Excel file forgets to do this.
Any other suggestions would be appreciated.
Thanks
I've been reading up on other solutions here and on the web and it seems your first post may be the best approach (use a ForEach file enumerator to grab the file names). I've also been reading up on using a ForEach ADO.NET Schema Rowset Enumerator to get the worksheets within each Excel file.
My initial thought was that the Excel Object Model would do what I needed it to do (I'm a VB/VBA programmer, and could do what I need using VB script), and did not post the whole task I need to accomplish. So let me state it now.
I need to:
1. Read Excel files from a folder. Each file is named differently, and the worksheets with data are also named differently
2. Load the data to SQL Server (not a problem, I have an SSIS Data Task that works well)
3. Move and rename the Excel files to another folder
I can use the ForEach File Enumerator to get the files and set the Excel connection in the data task. The issue is the worksheet name, which changes with each file. I've read on ms.com how to enumerate an Excel workbook and get the worksheet names:
http://msdn.microsoft.com/
The problem that I have with this solution is configuring the ADO.NET connection manager for Excel. They say to use the Jet OLE DB provider, however that provider only connects to Access and not Excel.
Are you familiar with using the ForEach ADO.NET Schema Rowset Enumerator to get Excel worksheets, and configuring the ADO.NET connection manager for Excel?
Thanks
Jet does also work for Excel. Did you try the instructions in that post? Just be aware that if you are running your SSIS as a job under 64 bit SQL Server there are some complications as there is no 64 bit Jet driver.
If the instructions in the web page are unclear I'd happily try it myself and post up what I find. (I learn as much from this site as I contribute).
We're running 32 bit SQL Server and BIDS. I'm going to try this again and send more detailed info.
The web page you directed me to has helped. I added the Quit() method of the Excel object, which destroys the reference in code. I believe the .NET Schema...Enumerator would work best if I can get that to work. I'll try a few things and post back later.
Thanks!
Business Accounts
Answer for Membership
by: nmcdermaidPosted on 2009-09-24 at 04:06:12ID: 25411927
This does not answer your question but I think you may have over complicated it a little.
1. If you use the SSIS for each file iterator, you can load the name of the file (whatever it is) into a variable, and in turn feed that variable into your data pump, so a rename is not necessary.
2. You could use standard file copies to rename an XLS file - there's no need to use the Excel object model (and therefore no need to install it on your server).. unless you do need the change the worksheet name.