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

Is there a way to detect in VB if the user did a Save Vs a SaveAs command.

Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Save vs SaveAs

There is.

Put this in the "ThisWorkbook" module

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI Then
MsgBox ("You did a SAVEAS")
Else
MsgBox ("You did a SAVE")
End If

End Sub

I've not used it much so had to play a bit. I'm not sure how the CANCEL
works.
--
HTH,
Barb Reinhardt



"Sandy" wrote:

Is there a way to detect in VB if the user did a Save Vs a SaveAs command.

Thank you.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Save vs SaveAs

Barb wrote:
<< I'm not sure how the CANCEL works.

From the Excel topic for the Workbook_BeforeSave event:
"If the event procedure sets this argument to True, the workbook isn't
saved when the procedure is finished."

Most events have this Cancel argument. It is used by the VBA programmer
(you) to tell Excel whether you want it to go ahead and run the normal
routine after your event handler has finished or not. Usually, you
simply want to intercept the function, insert some customized activity
of some sort, then continue with the normal Excel action. But sometimes,
you decide that you want to skip the rest of the default Excel behavior
for some reason. For example, you might want to skip Saving the
workbook, if the user had not selected the "SaveAs" command to give the
workbook a new name after making some changes. In this case, in the Else
part of the If statement, you would set Cancel to TRUE after displaying
the message box. This would force the user to use SaveAs and rename the
workbook while saving it. You would want to be sure to display a very
clear message that the workbook has NOT been saved!
--
Regards,
Bill Renaud



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
SaveAs command doesn't save extension stewart Excel Programming 4 April 9th 07 01:49 AM
disable save and saveas from menubar and save via command button Steve E Excel Programming 5 September 13th 06 11:51 PM
Disabling SaveAs and Save? Petitboeuf Excel Discussion (Misc queries) 7 July 6th 06 05:40 PM
Save or SaveAs Macro knosalaa Excel Programming 2 March 7th 06 02:35 AM
Detecting Save vs SaveAs in BeforeSave Aaron[_9_] Excel Programming 2 June 3rd 04 11:16 AM


All times are GMT +1. The time now is 09:58 PM.

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"