I want a VBA CODE to forbidden from copying the sheetsin this excel file to a new excel files or move to before or after other sheets. For example, SHEET1,SHEET2,....,SHEETn in one excel workbook, The n worksheets from SHEET1 to SHEETn are not permit to creat copies in a new file(It is not allowed to right-click the sheet name to select the 'Copy or Move to' menu) , I try many ways but also fail, for example:
Private Sub Workbook_Activate()
Dim ctl As Object
For Each ctl In Application.CommandBars("Worksheet Menu Bar").Controls
If ctl.ID = 244 Then
ctl.Enabled = False
Exit For
End If
Next ctl
End Sub
or other is not work also:
Private Sub Workbook_Activate()
'For Each ctl In Application.CommandBars.FindControls(ID:=847) '(&D)
' ctl.Enabled = False
'Next
For Each ctl In Application.CommandBars.FindControls(ID:=848) '(&M)...
ctl.Enabled = False
Next
For Each ctl In Application.CommandBars.FindControls(ID:=852) '(&W)
ctl.Enabled = False
Next
For Each ctl In Application.CommandBars.FindControls(ID:=889) '(&R)
ctl.Enabled = False
Next
'For Each ctl In Application.CommandBars.FindControls(ID:=945) '(&I)...
' ctl.Enabled = False
'Next
For Each ctl In Application.CommandBars.FindControls(ID:=946) '(&S)
ctl.Enabled = False
Next
'For Each ctl In Application.CommandBars.FindControls(ID:=21) '
' ctl.Enabled = False
'Next
'For Each ctl In Application.CommandBars.FindControls(ID:=19) '
' ctl.Enabled = False
'Next
'For Each ctl In Application.CommandBars.FindControls(ID:=22) '
' ctl.Enabled = False
'Next
'Application.DisplayAlerts = False
'Application.OnKey "^v", ""
'Application.OnKey "^c", ""
'Application.OnKey "^x", ""
Application.DisplayAlerts = True
End Sub
tahnks for your help, I want to settle, thanks.
Private Sub Workbook_Activate()
Dim ctl As Object
For Each ctl In Application.CommandBars("Worksheet Menu Bar").Controls
If ctl.ID = 244 Then
ctl.Enabled = False
Exit For
End If
Next ctl
End Sub
or other is not work also:
Private Sub Workbook_Activate()
'For Each ctl In Application.CommandBars.FindControls(ID:=847) '(&D)
' ctl.Enabled = False
'Next
For Each ctl In Application.CommandBars.FindControls(ID:=848) '(&M)...
ctl.Enabled = False
Next
For Each ctl In Application.CommandBars.FindControls(ID:=852) '(&W)
ctl.Enabled = False
Next
For Each ctl In Application.CommandBars.FindControls(ID:=889) '(&R)
ctl.Enabled = False
Next
'For Each ctl In Application.CommandBars.FindControls(ID:=945) '(&I)...
' ctl.Enabled = False
'Next
For Each ctl In Application.CommandBars.FindControls(ID:=946) '(&S)
ctl.Enabled = False
Next
'For Each ctl In Application.CommandBars.FindControls(ID:=21) '
' ctl.Enabled = False
'Next
'For Each ctl In Application.CommandBars.FindControls(ID:=19) '
' ctl.Enabled = False
'Next
'For Each ctl In Application.CommandBars.FindControls(ID:=22) '
' ctl.Enabled = False
'Next
'Application.DisplayAlerts = False
'Application.OnKey "^v", ""
'Application.OnKey "^c", ""
'Application.OnKey "^x", ""
Application.DisplayAlerts = True
End Sub
tahnks for your help, I want to settle, thanks.