excel continuing to run in the background

A

aross

Hi Folks
My app (Access 2003) is to produce spreadsheets for all operators within a
chosen region.
Once the user chooses the region I need to produce a separate excel file for
each operator within that region.
Each of these files may contain several worksheets depending on the number
of projects the operator handles.
In order to achieve this, I have a .xlt file with one Worksheet - Sheet1.
As the prog loops thru the projects for each organiser it makes a copy of
sheet1 for each project and populates it.
This works fine, and the prog correctly names and saves the xls file - the
problem arises when the loop swings back to the next operator in the
recordset.
Even although i am closing the workbook, (wkbXL.Close) and quitting the
Excel app
(appXL.Quit) and setting both wkbXL and appXL = nothing, when the loop comes
round, Excel is still running in the background.
The effect is that when the code gets back to the top and creates a new
excel app we have 2 apps running and subsequent code fails!!
How do I stop the instance of Excel so that I can start a new instance
thereafter?

Thanks for any help

Arthur
 
R

rumana

I'm encountering the same problem, and I'm wondering whether it's a bu
with the Excel Application Object or whether it's something wrong wit
our code.

In my app, I'm doing very similar things with the Word object as wit
the Excel object, and when I call objWord.Close and se
objWord=Nothing, the instance of Word stops running in the background.
objExcel.Close seems not to work.

Any insight is VERY appreciated
 
A

aross

My problem was my code.
I was copying the Worksheet with the following

Set appXL = New Excel.Application
Set wkbXL = appXL.Workbooks.Add

wkbXL.Worksheets(1).Copy After:=Worksheets(x)
Set wksXL = wkbXL.Worksheets(x + 1)

line 3 should read
wkbXL.Worksheets(1).Copy After:=wkbXL.Worksheets(x)

Since I had copied the syntax from the Excel Object Model, I forgot that the
reference to Worksheets needed to be prefixed by a reference to the excel
application instance, otherwise vba creates its own separate excel instance,
and it is this app that is not switched off despite the use of quit etc.

I suggest you look for any references to excel items that do not contain
explicit references to the excel application object.

this might help
www.dbforums.com/t698157.html

Good luck!!

Arthur
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top