Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Automatically perform action when closing Excel Worksheet

I want a message box to come up when I close an Excel worksheet

In the "This Workbook" module I have inserted the following code

Private Sub Workbook_Close()

MsgBox "This Worksheet is now closing"

End Sub

When I click on F5 in Visual Basic Editor, it works, but when I close the
document, it doesn't.

Any ideas?

Many thanks

Kindest regards

PaddyMac
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Automatically perform action when closing Excel Worksheet

Double click 'This Workbook' and see the drop downs on the right code module
to see the workbook events...

'Remove your code and copy paste the below and try
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "This Worksheet is now closing"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"PaddyMac" wrote:

I want a message box to come up when I close an Excel worksheet

In the "This Workbook" module I have inserted the following code

Private Sub Workbook_Close()

MsgBox "This Worksheet is now closing"

End Sub

When I click on F5 in Visual Basic Editor, it works, but when I close the
document, it doesn't.

Any ideas?

Many thanks

Kindest regards

PaddyMac

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Automatically perform action when closing Excel Worksheet

hi.
there isn't a workbook_close event. there is a workbook_beforeclose event
change the sub title to Sub WorkBook_BeforeClose(Cancel As Boolean)

regards
FSt1

"PaddyMac" wrote:

I want a message box to come up when I close an Excel worksheet

In the "This Workbook" module I have inserted the following code

Private Sub Workbook_Close()

MsgBox "This Worksheet is now closing"

End Sub

When I click on F5 in Visual Basic Editor, it works, but when I close the
document, it doesn't.

Any ideas?

Many thanks

Kindest regards

PaddyMac

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Automatically perform action when closing Excel Worksheet

Jacob

It works perfectly.

Many thanks!

Kindest regards

PaddyMac

"Jacob Skaria" wrote:

Double click 'This Workbook' and see the drop downs on the right code module
to see the workbook events...

'Remove your code and copy paste the below and try
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "This Worksheet is now closing"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"PaddyMac" wrote:

I want a message box to come up when I close an Excel worksheet

In the "This Workbook" module I have inserted the following code

Private Sub Workbook_Close()

MsgBox "This Worksheet is now closing"

End Sub

When I click on F5 in Visual Basic Editor, it works, but when I close the
document, it doesn't.

Any ideas?

Many thanks

Kindest regards

PaddyMac

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Automatically perform action when closing Excel Worksheet

Perfect!

Thank you so much!

Kindest regards

PaddyMac

"FSt1" wrote:

hi.
there isn't a workbook_close event. there is a workbook_beforeclose event
change the sub title to Sub WorkBook_BeforeClose(Cancel As Boolean)

regards
FSt1

"PaddyMac" wrote:

I want a message box to come up when I close an Excel worksheet

In the "This Workbook" module I have inserted the following code

Private Sub Workbook_Close()

MsgBox "This Worksheet is now closing"

End Sub

When I click on F5 in Visual Basic Editor, it works, but when I close the
document, it doesn't.

Any ideas?

Many thanks

Kindest regards

PaddyMac

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
Need to perform action on range Mike G.[_3_] Excel Programming 3 March 3rd 07 10:29 PM
Perform action on every workbook in a directory Btibert[_8_] Excel Programming 2 February 6th 06 07:33 PM
How to 'Click and then perform action' chris100[_7_] Excel Programming 14 August 2nd 05 02:57 PM
How to perform action in all worksheets Sethaholic Excel Programming 6 July 11th 05 07:44 PM
Perform action when cell is clicked Jason[_26_] Excel Programming 3 October 4th 03 06:08 PM


All times are GMT +1. The time now is 07:23 PM.

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

About Us

"It's about Microsoft Excel"