Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Save Event Handler

I am trying to "force" my user to use the "save" subroutine i have written
which utilizes the GetSaveAsFilename method with a customized dialog and a
default filename. is there a way to bypass excel asking the user if they
want to save if they either try to close the workbook or click the save
button.
i attempted this already using the workbook_beforeclose event handler and in
that subroutine, put my getsaveasfilename method and it prompeted the user to
save again and when it went to close the workbook finally, ran through the
beforeclose event handler again. any help is appreciated, TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Save Event Handler

Try code like the following in the ThisWorkbook module:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim FName As Variant
On Error GoTo ExitSub
If SaveAsUI = True Then
Cancel = True
FName = Application.GetSaveAsFilename(FileFilter:="Excel Files
(*.xls),*.xls")
If FName = False Then
' user cancelled
Else
Application.DisplayAlerts = False
Application.EnableEvents = False
ThisWorkbook.SaveAs Filename:=FName
End If
End If

ExitSub:

Application.EnableEvents = True
Application.DisplayAlerts = True

End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Spencer" wrote in message
...
I am trying to "force" my user to use the "save" subroutine i have written
which utilizes the GetSaveAsFilename method with a customized dialog and
a
default filename. is there a way to bypass excel asking the user if they
want to save if they either try to close the workbook or click the save
button.
i attempted this already using the workbook_beforeclose event handler and
in
that subroutine, put my getsaveasfilename method and it prompeted the user
to
save again and when it went to close the workbook finally, ran through the
beforeclose event handler again. any help is appreciated, TIA



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
event handler list travis Excel Programming 2 July 26th 06 02:48 PM
Event handler VBA Noob[_4_] Excel Programming 4 April 26th 06 03:49 PM
Autoshape event handler? [email protected] Excel Programming 7 February 23rd 06 10:12 PM
Event handler is invalid Minh[_2_] Excel Programming 2 December 8th 05 02:00 AM
where is the workbook_open event handler??? Steff_DK[_10_] Excel Programming 2 April 25th 04 02:43 PM


All times are GMT +1. The time now is 06:52 AM.

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"