Problem closing Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

I'm having a weird problem in that Excel doesn't seem to be closing down completely and it's causing problems because of it. I open Excel from within Access, do some stuff on an existing Excel file (set cells, formatting, etc), and then shut Excel down. When I do CTRL-ALT-DEL and then go to "Task Manager" in W2K, I notice Excel still appears to be running, as if it's not being completely shut down. This is the sequence I'm using to shut it down. Does anyone see problems with it?:

objWB.Save
objWB.Close
Set objSheet = Nothing
Set objWB = Nothing

objXL.Quit
Set objXL = Nothing


Thanks in advance for any help!

Dan
 
application.quit works for our group



Dan said:
Hi!

I'm having a weird problem in that Excel doesn't seem to be closing down
completely and it's causing problems because of it. I open Excel from
within Access, do some stuff on an existing Excel file (set cells,
formatting, etc), and then shut Excel down. When I do CTRL-ALT-DEL and then
go to "Task Manager" in W2K, I notice Excel still appears to be running, as
if it's not being completely shut down. This is the sequence I'm using to
shut it down. Does anyone see problems with it?:
 
Chances are that you're setting an implicit object reference in your code
before this part, where you're not fully qualifying a reference to an object
in EXCEL. Can be as subtle ....

Post your code and let's see all of it.

--

Ken Snell
<MS ACCESS MVP>

Dan said:
Hi!

I'm having a weird problem in that Excel doesn't seem to be closing down
completely and it's causing problems because of it. I open Excel from
within Access, do some stuff on an existing Excel file (set cells,
formatting, etc), and then shut Excel down. When I do CTRL-ALT-DEL and then
go to "Task Manager" in W2K, I notice Excel still appears to be running, as
if it's not being completely shut down. This is the sequence I'm using to
shut it down. Does anyone see problems with it?:
 
Well, here's the sub where I run Excel, but on another note, it doesn't seem to be happening anymore. I shut the machine off then back on, and for now, that "cured" it. Little disconcerting since I still don't know why it was happening...

Thanks so much for the help!

Dan


**************************************************
Sub FormatSpreadsheet(FileToFormat As String)

Dim objXL As Excel.Application
Dim objWB As Excel.Workbook
Dim objSheet As Excel.Worksheet

Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.Workbooks.Open(FileToFormat)

Set objSheet = objWB.Worksheets(1)

'Clear the comments that got put in cell A1 during transfer
objXL.Cells(1, 1).ClearComments

'Set Font, Font size
objXL.Columns("A:Z").Font.Name = "Tahoma"
objXL.Columns("A:Z").Font.Size = 8
'Set Horiz. alignment to LEFT, Vert. alignment to TOP, WrapText=TRUE
objXL.Columns("A:Z").HorizontalAlignment = xlLeft
objXL.Columns("A:Z").VerticalAlignment = xlTop
objXL.Columns("A:Z").WrapText = True


'Set the column widths
objXL.Columns("A:A").ColumnWidth = 9
objXL.Columns("B:B").ColumnWidth = 15.43
objXL.Columns("C:C").ColumnWidth = 37.43
objXL.Columns("D:D").ColumnWidth = 9.14
objXL.Columns("E:E").ColumnWidth = 42.14
objXL.Columns("F:F").ColumnWidth = 9.57
objXL.Columns("G:G").ColumnWidth = 10
objXL.Columns("H:H").ColumnWidth = 10.43
objXL.Columns("I:I").ColumnWidth = 37.43
objXL.Columns("J:J").ColumnWidth = 37.43
objXL.Columns("K:K").ColumnWidth = 8.86
objXL.Columns("L:L").ColumnWidth = 9.14
objXL.Columns("M:M").ColumnWidth = 9.71

'Set the row heights to auto-fit
objXL.Rows("2:5000").EntireRow.AutoFit

'Color the header and RID columns
objXL.Rows("1:1").Interior.ColorIndex = 55
objXL.Rows("1:1").Font.ColorIndex = 2
objXL.Range("A2:A5000").Interior.ColorIndex = 41
objXL.Range("A2:A5000").Font.ColorIndex = 2


'Color the header and RID columns
objXL.Range("B2").Select
objXL.ActiveWindow.FreezePanes = True


GoTo FinishUp



FinishUp:

' To save and quit, simply do this
objWB.Save
objWB.Close
Set objSheet = Nothing
Set objWB = Nothing

objXL.Quit
Set objXL = Nothing

End Sub
**************************************************
 
My guess would be that you're using objXL as the only reference for the
properties related to the worksheet. As such, EXCEL may be "inserting"
default objects to complete the reference: ActiveSheet and ActiveWorkbook.

That may be the source of your problem.

Try using the objSheet object instead of objXL when you use the worksheet
properties such as Columns, Range, etc.

--

Ken Snell
<MS ACCESS MVP>

Dan said:
Well, here's the sub where I run Excel, but on another note, it doesn't
seem to be happening anymore. I shut the machine off then back on, and for
now, that "cured" it. Little disconcerting since I still don't know why it
was happening...
 
Thanks, Ken. I tried it with the "sheet" reference and it still works, so I'll try this and see how robust it is. I really appreciate your help!

Dan
 
Back
Top