View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
deko[_2_] deko[_2_] is offline
external usenet poster
 
Posts: 53
Default Excel not quitting - How to avoid global reference?

I'm using Access 2000 to create charts in Excel. I've read about the
problem Excel not quitting due to a global reference to the automated
application at http://www.tushar-mehta.com/excel/vba/xl_doesnt_quit/

So I've tried to reference objects explicitly. For example:

With xlapp.Workbooks(strXlsFile).Worksheets(sn(i))
.[do stuff]
End With

But Excel still does not quit.

Sometimes I need to assign the return value of a method to an object - when
creating a chart or adding a series, for example:

Dim objChart as Object
Set objChart = xlapp.Workbooks(strXlsFile). _
Worksheets(sn(i)).ChartObjects.Add(Left:=100, Top:=24, _
Width:=650, Height:=500).Chart
With ObjChart
.[do stuff]
End with

Dim objSeries as Object
Set objSeries = objChart.SeriesCollection.NewSeries
With objSeries
.[do stuff]
End With

Is this why Excel is not quitting? Do either of the above two examples
constitute a global reference? Can this code be written so it does not
create a global reference? Could there be some other reason why Excel is
not quitting?

Thanks in advance.