Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Private Sub Workbook_BeforeSave

I am using this to run macros before and after a save event. Save &
SaveAs do the same thing. Can I have a second routine that does a Save
without asking for file and permission to overwrite?
SaveAs would be as below. TIA
____________________________________________

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
On Error GoTo PrintingOver
Application.EnableEvents = False
Call Workbook_2
Dim varResponse As Variant
varResponse = Application.GetSaveAsFilename( _
FileFilter:="Microsoft Excel Workbook (*.xls), *.xls")
If varResponse = False Then
'do nothing except exit
ElseIf varResponse = Me.FullName Then
MsgBox "Please save under a different name. "
Else
ThisWorkbook.SaveAs varResponse
End If

Call Workbook_2
PrintingOver:
Application.EnableEvents = True
Cancel = True
End Sub
-----------
by Jim Cone

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Private Sub Workbook_BeforeSave

How can I tell if the Save or SaveAs button was pushed?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default Private Sub Workbook_BeforeSave

Also, how do I detect if it is just a regular Save or if it is closing
the workbook and trying to save? How do I detect it is closing?

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
Improve method of calling a private function in a private module XP Excel Programming 1 April 30th 08 06:41 PM
re : Possible to run private sub macros by writing another private ddiicc Excel Programming 5 August 26th 05 04:49 AM
Private Sub Running Other Private Sub Inadvertently Ross Culver Excel Programming 2 February 10th 05 07:17 PM
Workbook_BeforeSave Bill Oertell Excel Programming 5 December 21st 03 07:33 PM
Workbook_BeforeSave() in xla Bent Kjeldsen Excel Programming 6 September 24th 03 01:49 PM


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