Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 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!




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Code req to close all workbooks Neil Atkinson Excel Programming 2 September 23rd 05 01:46 PM
VBA Code req to close all workbooks Neil Atkinson Excel Programming 0 September 23rd 05 11:06 AM
close code Shawn Excel Programming 1 September 20th 05 02:49 PM
Code to close workbook Mason Excel Programming 10 March 29th 05 08:58 AM
Close VB in Code Paul Watkins[_2_] Excel Programming 2 December 17th 03 09:25 PM


All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"