Disable save

G

Guest

I have a excel file that I'm trying to prevent someone from saving as or
coping data. I have disabled the "Save", "Save as..", and the copy commands.
But I notice when someone select the entire sheet (Ctrl - A) the copy command
is still available on the right click menu. How do I disable this?
 
J

Jim Rech

Actually there are many instances of the Copy command (32) sprinkled among
the commandbars. To get them all:

Sub DisableCopyCtrl()
Dim Ctrls As CommandBarControls
Dim Ctrl As CommandBarControl
Set Ctrls = CommandBars.FindControls(, 19)
For Each Ctrl In Ctrls
Ctrl.Enabled = False
Next
End Sub

Be sure to Enable on exit as this change is saved in the user's
configuration.

But you know if the user disables macros when opening your workbook he'll be
able to copy as he pleases...

--
Jim
|I have a excel file that I'm trying to prevent someone from saving as or
| coping data. I have disabled the "Save", "Save as..", and the copy
commands.
| But I notice when someone select the entire sheet (Ctrl - A) the copy
command
| is still available on the right click menu. How do I disable this?
 
G

Guest

Thanks Jim that works great.
I have my sheets very hidden with code that unhides them on open. If macros
are not enable they can't see anything.
 
S

Silena K-K

Hi

I am very new to VB and have tried Jim's code below to disable the copy
command in user templates I am creating however it didn't work.

I went into VB (Alt + F11) and pasted the code into the ThisWorkbook module.
Is that correct??

Also I didn't know what Jim meant about "ensure to enable on exit".

Can someone help please??

Thanks and Merry Christmas. Silena
 
R

Ron de Bruin

Hi Silena

Copy both in a normal module
http://www.rondebruin.nl/code.htm

Sub MenuControl_False()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=19)
Ctrl.Enabled = False
Next Ctrl
End Sub

Sub MenuControl_True()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=19)
Ctrl.Enabled = True
Next Ctrl
End Sub

Then in the Thisworkbook module use

Private Sub Workbook_Activate()
Call MenuControl_False
End Sub

Private Sub Workbook_Deactivate()
Call MenuControl_True
End Sub






Read also the info here
http://www.rondebruin.nl/menuid.htm

..
 

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