PC Review


Reply
Thread Tools Rate Thread

Automatically perform action when closing Excel Worksheet

 
 
PaddyMac
Guest
Posts: n/a
 
      9th Oct 2009
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 With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      9th Oct 2009
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

 
Reply With Quote
 
FSt1
Guest
Posts: n/a
 
      9th Oct 2009
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 With Quote
 
PaddyMac
Guest
Posts: n/a
 
      12th Oct 2009
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

 
Reply With Quote
 
PaddyMac
Guest
Posts: n/a
 
      12th Oct 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function to perform on closing an Excel Workbook PaddyMac Microsoft Excel Programming 4 28th Oct 2009 05:55 AM
Outputto action to automatically replace an excel file =?Utf-8?B?UGhpbCBGZXJndXNvbg==?= Microsoft Access Macros 3 22nd Dec 2004 12:51 PM
Windows can perform the same action... !Sparky Windows XP Basics 2 28th Aug 2004 12:54 PM
Automatically Closing a worksheet after 10 mins Neil Microsoft Excel Programming 1 9th Feb 2004 10:05 AM
asp.net automatically perform action based on a date CoX Microsoft ASP .NET 3 30th Dec 2003 04:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:21 PM.