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

I am having problems getting this event to kick in. I need to intercept any
attempt to use the File Save menu or icon to make sure that the user's name
is captured (I do that on the Workbook Close event). I have just tried the
Help sample code (below) but cannot get that to work. Any ideas, please?

Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel as Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub


JMCS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default workbook beforesave event

It needs to be in THISWORKBOOK module of the VBA code.

Books event are in Thisworkbook
Sheet events must match the sheet in the worksheet where you want the event
to occur.

"JMCS" wrote:

I am having problems getting this event to kick in. I need to intercept any
attempt to use the File Save menu or icon to make sure that the user's name
is captured (I do that on the Workbook Close event). I have just tried the
Help sample code (below) but cannot get that to work. Any ideas, please?

Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel as Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub


JMCS

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default workbook beforesave event

First of all many thanks for the quick response. However, that is where it
is in both my 'real' file and the 'test the beforesave event only' file. In
my 'real' file I have a beforeclose event and that works like a treat.

Regards
JMCS

"Joel" wrote:

It needs to be in THISWORKBOOK module of the VBA code.

Books event are in Thisworkbook
Sheet events must match the sheet in the worksheet where you want the event
to occur.

"JMCS" wrote:

I am having problems getting this event to kick in. I need to intercept any
attempt to use the File Save menu or icon to make sure that the user's name
is captured (I do that on the Workbook Close event). I have just tried the
Help sample code (below) but cannot get that to work. Any ideas, please?

Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel as Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub


JMCS

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default workbook beforesave event

the procedure name you use,"App_WorkbookBeforeSave", isn't event driven
afaik. Use the workbook event...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

IF MsgBox("Do you really want to save the workbook?", vbYesNo)=vbNo Then
Cancel = True
END IF

End Sub


"JMCS" wrote:

I am having problems getting this event to kick in. I need to intercept any
attempt to use the File Save menu or icon to make sure that the user's name
is captured (I do that on the Workbook Close event). I have just tried the
Help sample code (below) but cannot get that to work. Any ideas, please?

Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel as Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub


JMCS

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default workbook beforesave event

Joel was right, but my mistake was simply copying and pasting the Help code.
Reworking it got it to do what was required.

"JMCS" wrote:

First of all many thanks for the quick response. However, that is where it
is in both my 'real' file and the 'test the beforesave event only' file. In
my 'real' file I have a beforeclose event and that works like a treat.

Regards
JMCS

"Joel" wrote:

It needs to be in THISWORKBOOK module of the VBA code.

Books event are in Thisworkbook
Sheet events must match the sheet in the worksheet where you want the event
to occur.

"JMCS" wrote:

I am having problems getting this event to kick in. I need to intercept any
attempt to use the File Save menu or icon to make sure that the user's name
is captured (I do that on the Workbook Close event). I have just tried the
Help sample code (below) but cannot get that to work. Any ideas, please?

Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel as Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub


JMCS

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
Use Workbook BeforeSave Event to Save Copy to Different Location RyanH Excel Programming 9 October 23rd 08 07:48 PM
How do I change a Worksheet_change event to a beforesave event? Tueanker Excel Programming 5 June 29th 07 03:00 PM
Protect Worksheet / Workbook in BeforeSave Event tc69 Excel Programming 2 April 23rd 07 11:00 AM
BeforeSave sub won't save another workbook when triggered by another event sub Brad Yundt Excel Programming 1 June 3rd 04 03:12 AM
BeforeSave workbook event Cindy Excel Programming 15 February 10th 04 04:28 PM


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