Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Closing a workbook...

I've written some code in the Workbook_BeforeClose( ) routine. It basically
clears and resets values in a spreadsheet before closing and the last line
of the subroutine is a Workbook.Save command (or something like that) and it
saves the changes without prompting me if I want to save them.

Up until now it's working perfectly but I've been using the 'x' from the
upper right hand corner of the window. Now I'm trying to create a custom
menu with an Exit command to use that to close the workbook in place of the
Close window command, 'x'.

I've coded the routine as follows:

Sub mcrShutDown ( )

ThisWorkbook.Saved = True
Application.Workbook.Close

End Sub

There are 2 problems: 1) I'm getting prompted to save changes and 2) it's
not running the Workbook_BeforeClose routine so my program doesn't get
reset.

What am I missing? How come the Workbook_BeforeClose routine isn't running?

Jeff


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Closing a workbook...

Hello,

I'm not sure Application.Workbook.Close exists
its either Application.Quit or ThisWorkBook.Close
Also ThisWorkBook.Saved = True tells excel that the
workbook doesn't need saving.

Leave all your reseting and ThisWorkBook.Save in teh
BeforeClose event and just put ThisWorkBook.Close in the
Exit event.

It's also possible to disable the x in the corner.

HTH



-----Original Message-----
I've written some code in the Workbook_BeforeClose( )

routine. It basically
clears and resets values in a spreadsheet before closing

and the last line
of the subroutine is a Workbook.Save command (or

something like that) and it
saves the changes without prompting me if I want to save

them.

Up until now it's working perfectly but I've been using

the 'x' from the
upper right hand corner of the window. Now I'm trying to

create a custom
menu with an Exit command to use that to close the

workbook in place of the
Close window command, 'x'.

I've coded the routine as follows:

Sub mcrShutDown ( )

ThisWorkbook.Saved = True
Application.Workbook.Close

End Sub

There are 2 problems: 1) I'm getting prompted to save

changes and 2) it's
not running the Workbook_BeforeClose routine so my

program doesn't get
reset.

What am I missing? How come the Workbook_BeforeClose

routine isn't running?

Jeff


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Closing a workbook...

A work around for your second problem would be to switch
the "clear" the worksheet code from the before close to
the Workbook_Open() routine.


-----Original Message-----
I've written some code in the Workbook_BeforeClose( )

routine. It basically
clears and resets values in a spreadsheet before closing

and the last line
of the subroutine is a Workbook.Save command (or

something like that) and it
saves the changes without prompting me if I want to save

them.

Up until now it's working perfectly but I've been using

the 'x' from the
upper right hand corner of the window. Now I'm trying to

create a custom
menu with an Exit command to use that to close the

workbook in place of the
Close window command, 'x'.

I've coded the routine as follows:

Sub mcrShutDown ( )

ThisWorkbook.Saved = True
Application.Workbook.Close

End Sub

There are 2 problems: 1) I'm getting prompted to save

changes and 2) it's
not running the Workbook_BeforeClose routine so my

program doesn't get
reset.

What am I missing? How come the Workbook_BeforeClose

routine isn't running?

Jeff


.

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
Help with closing down a workbook?? Don Excel Worksheet Functions 1 May 9th 05 04:05 AM
Closing workbook Ed Excel Programming 4 February 6th 04 03:41 PM
closing excel after closing a workbook CWalsh[_2_] Excel Programming 3 January 21st 04 03:33 PM
Closing a workbook Belinda Excel Programming 2 January 15th 04 01:27 PM
closing workbook Sam Dickins Excel Programming 1 November 27th 03 03:43 PM


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