ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to close app in code? (https://www.excelbanter.com/excel-programming/341992-how-close-app-code.html)

homer

how to close app in code?
 
I know this should be very simple. BUT I just could not get it work, and I
did not find any documentation on how to close an excel app from MSDN.

I created the app in vb6 as,
Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Add
Set xlWs = xlWb.Worksheets("Sheet1")
and after populated the sheet,
xlWb.Saveas ("C:\northwind\mynwtbl.xls")
' xlWb.Close
With above line the only the workbook closed, but not excel itself.
' xlApp.Windows("C:\northwind\mynwtbl.xls").Close
With above line I got "subscript out of range" error.
'Set xlApp = Nothing
No working either.

Thanks!

Bob Phillips[_12_]

how to close app in code?
 
Try

xlApp.Quit

HTH

Bob

"homer" wrote in message
...
I know this should be very simple. BUT I just could not get it work, and I
did not find any documentation on how to close an excel app from MSDN.

I created the app in vb6 as,
Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Add
Set xlWs = xlWb.Worksheets("Sheet1")
and after populated the sheet,
xlWb.Saveas ("C:\northwind\mynwtbl.xls")
' xlWb.Close
With above line the only the workbook closed, but not excel itself.
' xlApp.Windows("C:\northwind\mynwtbl.xls").Close
With above line I got "subscript out of range" error.
'Set xlApp = Nothing
No working either.

Thanks!




Tom Ogilvy

how to close app in code?
 
Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Add
Set xlWs = xlWb.Worksheets("Sheet1")
and after populated the sheet,
xlWb.Saveas ("C:\northwind\mynwtbl.xls")
xlWb.Close
set xlWb = Nothing
xlApp.Quit
Set xlApp = Nothing

--
Regards,
Tom Ogilvy


"homer" wrote in message
...
I know this should be very simple. BUT I just could not get it work, and I
did not find any documentation on how to close an excel app from MSDN.

I created the app in vb6 as,
Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Add
Set xlWs = xlWb.Worksheets("Sheet1")
and after populated the sheet,
xlWb.Saveas ("C:\northwind\mynwtbl.xls")
' xlWb.Close
With above line the only the workbook closed, but not excel itself.
' xlApp.Windows("C:\northwind\mynwtbl.xls").Close
With above line I got "subscript out of range" error.
'Set xlApp = Nothing
No working either.

Thanks!




homer

how to close app in code?
 
Thanks Bob and Tom!

"Tom Ogilvy" wrote:

Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Add
Set xlWs = xlWb.Worksheets("Sheet1")
and after populated the sheet,
xlWb.Saveas ("C:\northwind\mynwtbl.xls")
xlWb.Close
set xlWb = Nothing
xlApp.Quit
Set xlApp = Nothing

--
Regards,
Tom Ogilvy


"homer" wrote in message
...
I know this should be very simple. BUT I just could not get it work, and I
did not find any documentation on how to close an excel app from MSDN.

I created the app in vb6 as,
Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Add
Set xlWs = xlWb.Worksheets("Sheet1")
and after populated the sheet,
xlWb.Saveas ("C:\northwind\mynwtbl.xls")
' xlWb.Close
With above line the only the workbook closed, but not excel itself.
' xlApp.Windows("C:\northwind\mynwtbl.xls").Close
With above line I got "subscript out of range" error.
'Set xlApp = Nothing
No working either.

Thanks!






All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com