Hey All,
I have some VBA code in Word that opens Excel and puts values into a bunch of cells on several Worksheets, but only one workbook. Then when my code finishes I find that the Excel process is still running in the task manager. I thought I had used to proper code to close it properly but it doesn't seem to be working and I'm not sure why. My code is like this:
Any help to close Excel properly so that the process doesn't hang would be great.
Thanks,
BitNet
I have some VBA code in Word that opens Excel and puts values into a bunch of cells on several Worksheets, but only one workbook. Then when my code finishes I find that the Excel process is still running in the task manager. I thought I had used to proper code to close it properly but it doesn't seem to be working and I'm not sure why. My code is like this:
Code:
Dim xl as Object
Set xl = CreateObject("Excel.Application")
With xl.Workbooks.Add
Worksheets.Add.name = "Trend"
With ActiveSheet.name = "Trend"
'Put some values into cells...
End With
WorkSheets.Add.name = "More Trends"
With ActiveSheet.name = "More Trends"
'Put some values into cells...
End With
'Clean up
ActiveWorkbooks.SaveAs ("C:\Document...\File.xlsx")
ActiveWorkbook.Close
Workbooks.Close
xl.Quit
set xl = Nothing
End With
Thanks,
BitNet