Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Msgbox not working

I wrote the following to remind users to enter dates when they save the
worksheet/book:

Private Sub Workbook_BeforeSave()

MsgBox "Did you enter the dates?"

End Sub

But the message box doesn't show. The macro is in the sheet I'm saving.

Any ideas?
Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Msgbox not working

When you use an event it must match the event signature specified by VBA
and be in the correct code sheet. The BeforeSave event must be in the
ThisWorkbook module and should look something like this:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim ans As Long
ans = MsgBox("Did you enter the dates?", vbYesNo)
If ans = vbNo Then
Cancel = True
MsgBox "File not saved"
End If
End Sub

Hope this helps
Rowan

davegb wrote:
I wrote the following to remind users to enter dates when they save the
worksheet/book:

Private Sub Workbook_BeforeSave()

MsgBox "Did you enter the dates?"

End Sub

But the message box doesn't show. The macro is in the sheet I'm saving.

Any ideas?
Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Msgbox not working

Thanks, Rowan. You'd think Walkenbach would've mentioned it had to be
in the "ThisWorkbook" module!
BTW, it works just fine with just the message and defaulting to the
vbOkonly style.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Msgbox not working

I'm sure he does.

--
Regards,
Tom Ogilvy


"davegb" wrote in message
oups.com...
Thanks, Rowan. You'd think Walkenbach would've mentioned it had to be
in the "ThisWorkbook" module!
BTW, it works just fine with just the message and defaulting to the
vbOkonly style.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default Msgbox not working


Tom Ogilvy wrote:
I'm sure he does.

--
Regards,
Tom Ogilvy


"davegb" wrote in message
oups.com...
Thanks, Rowan. You'd think Walkenbach would've mentioned it had to be
in the "ThisWorkbook" module!
BTW, it works just fine with just the message and defaulting to the
vbOkonly style.


Any idea where it is? I looked through most of the referenced pages
from the index under "events" and "BeforeSave" before I posted my
original message. It's not in the 3 paragraphs in the detailed
description of BeforeSave on page 526. Might help me to figure out
where he puts things if I could find it.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Msgbox not working

John has written many books. So I can't say which you are talking about.
But if it isn't actually in that section then it would be in a general into
to events or perhaps in an intro to workbook level events.

It could as a simple and as subtle as

"These two event-handler procedures (which must be in the code module for
the ThisWorkbook object) are listed below."

which is on his site at

http://www.j-walk.com/ss/excel/tips/tip78.htm

A list of books at:

http://www.j-walk.com/ss/books/index.htm


"davegb" wrote in message
ups.com...

Tom Ogilvy wrote:
I'm sure he does.

--
Regards,
Tom Ogilvy


"davegb" wrote in message
oups.com...
Thanks, Rowan. You'd think Walkenbach would've mentioned it had to be
in the "ThisWorkbook" module!
BTW, it works just fine with just the message and defaulting to the
vbOkonly style.


Any idea where it is? I looked through most of the referenced pages
from the index under "events" and "BeforeSave" before I posted my
original message. It's not in the 3 paragraphs in the detailed
description of BeforeSave on page 526. Might help me to figure out
where he puts things if I could find it.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Msgbox not working

Excel 2002 Power Programming with VBA.

Page 233, 415, 500, 574, 575, 576, ... then I got tired.


davegb wrote:

Tom Ogilvy wrote:
I'm sure he does.

--
Regards,
Tom Ogilvy


"davegb" wrote in message
oups.com...
Thanks, Rowan. You'd think Walkenbach would've mentioned it had to be
in the "ThisWorkbook" module!
BTW, it works just fine with just the message and defaulting to the
vbOkonly style.


Any idea where it is? I looked through most of the referenced pages
from the index under "events" and "BeforeSave" before I posted my
original message. It's not in the 3 paragraphs in the detailed
description of BeforeSave on page 526. Might help me to figure out
where he puts things if I could find it.


--

Dave Peterson
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
Calculate working days but change working week SamB Excel Discussion (Misc queries) 1 September 1st 08 09:17 PM
msgbox yes or no choice[_2_] Excel Programming 2 April 9th 05 08:56 AM
Help with MsgBox... tjb Excel Worksheet Functions 3 December 29th 04 03:43 PM
Msgbox serge Excel Programming 1 January 28th 04 01:48 PM
Adding sales from a non working day to the previous working day Alex Excel Programming 1 September 19th 03 08:48 AM


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