In Excel 2003 is there a way to prevent "Save As" and "Print"?

B

Bernie Deitrick

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
End Sub

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


Copy the above code into the Thisworkbook codemodule. Note that they will be defeated easily by any
knowledgeable user....

HTH,
Bernie
MS Excel MVP
 
L

lucky2000

Thank you for your response, one more question if I may persist.... can
'copy/paste' also be defeated in some easy fashion as
'save as' and 'print' were in your explanation?
 
B

Bernie Deitrick

Yes, sort of, kind of, not as reliably....

This should prevent copying a range and pasting it over itself:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Application.CutCopyMode <> False Then
With Application
.EnableEvents = False
.Undo
.CutCopyMode = False
.EnableEvents = True
End With
End If
End Sub

This will prevent copying one range and pasting over another range:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Application.CutCopyMode <> False Then Application.CutCopyMode = False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top