LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Closing Excel When Using CreateObject to Open It

I have code in an Access module that opens an Excel file using CreateObject.
I have a lot of code in the Excel file and the user's only interaction in
Excel is via five buttons I offer, one of which is a "Save & Close" button.
Everything works fine EXCEPT Excel does not close when "Save & Close" is
clicked. The workbook closes, but Excel does not. Below is my code in the
Excel module that I use to save the workbook and close it, then quit Excel,
but the "Application.Quit" statement is skipped (I used a break to watch what
happens). It all closes fine when I open the file on my own (double clicking
the xls file), but when I open it via the Access function I created, only the
workbook closes, not the Excel application. I do not have a "Quit" statement
in the Access function I created because the user needs to interact and use
Excel, so I can't use Access to close Excel right after it opens it. I guess
it's not a crime if Excel is left running after the user modifies the
workbook, but I would like to close Excel completely if possible.

Sub CloseWorkBook()
On Error Resume Next
Application.Caption = "Microsoft Excel"
Application.WindowState = xlMaximized
RestoreToolbars
AppActivate "Microsoft Access"
Sheets("Sheet1").Select
ThisWorkbook.Close (True)
Application.Quit
End Sub
 
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
Excel program remains open after closing file RPC Excel Discussion (Misc queries) 9 February 7th 08 07:59 PM
Use CreateObject to add a new module to Excel Chip Pearson Excel Programming 0 November 30th 06 10:55 PM
Prevent open excel windows from automatically closing. Prevent Automatic Closing Excel Discussion (Misc queries) 1 April 10th 06 10:27 PM
Excel CreateObject on server Dennis Redfield Excel Programming 9 July 15th 05 10:09 PM
How do I stop Excel from closing the open file each time I open a. Welsin Setting up and Configuration of Excel 3 January 8th 05 11:16 PM


All times are GMT +1. The time now is 12:00 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"