View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default How to block file Save (^S)?

George,

The SaveAsUI (Save As from User Interface -- the FileSave As
operation) indicates whether the save was initiated by the user
or by code. If by the user, SaveAsUI will be True, otherwise
False. The Cancel variable allows you to cancel the save
operation. Setting it to True will cancel the save.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"G Lykos" wrote in message
...
Tom, thanks for your reply. Yes, intercepting the Save via the
associated
event seems logical.

Looked at your example below and Pearson's EventSeq.xls.
Having parameters
for an event Sub triggered automatically upon event occurrence
is
unfamiliar. Cancel must be an outbound results parameter for
the Sub, but
what does the UI in SaveAsUI represent as a mnemonic, and where
are it and
Cancel defined? Is SaveAsUI a common Excel flag that the
analysis macro can
reset, to be picked up by your event Sub below?

Thanks again,
George


"Tom Ogilvy" wrote in message
...
You might use the beforesave event:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean,
Cancel As
Boolean)
If Not SaveAsUI Then
Cancel = True
End If
End Sub

If macros are disable, this of course will not work.

If you not familiar with events see Chip Pearson's page
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy

"G Lykos" wrote in message
...
What can be done in VBA such that <CTRL<S will be blocked
from saving

a
spreadsheet file?

Situation is that a macro has manipulated the spreadsheet
for the

purposes
of analysis, and I would like to then block the user from
inadvertently
Save-ing this version of the file - but perhaps allow Save
As.

Thanks,
George