Attaching code to one single excel file only

tanmay_79

New Member
Joined
Jan 25, 2005
Messages
2
Hi guys,

From all the help I got from this forum I created a Single Sheet Excel File and used the following code.

Following are the problems which I need to resolve.
1. Whenever I start excel all the commands mentioned for this file are disabled for all new files by default. Thus I cant create any new file ....
I want that menu actions from this particular file shud be disabled but available to other files.

2. Disabling Insert menu commands does not work????

3. Will this code work on Excel 97 ? I am using Excel XP but my client has 97...

Thanks
Tanmay.


Heres the code...
=====================================================
Private Sub ThisWorkbook_Activate()

' Turn off the menu
Application.CommandBars("File").Controls(1).Enabled = False
Application.CommandBars("File").Controls(2).Enabled = False
'Application.CommandBars("File").Controls(4).Enabled = True
Application.CommandBars("File").Controls(5).Enabled = False
Application.CommandBars("File").Controls(6).Enabled = False

Application.CommandBars("Insert").Controls(1).Enabled = False
Application.CommandBars("Insert").Controls(2).Enabled = False
Application.CommandBars("Insert").Controls(3).Enabled = False

Application.CommandBars("Edit").Controls(3).Enabled = False
Application.CommandBars("Edit").Controls(3).Enabled = False
Application.CommandBars("Edit").Controls(4).Enabled = False
Application.CommandBars("Edit").Controls(5).Enabled = False
Application.CommandBars("Edit").Controls(6).Enabled = False

' Turn off the toolbar:
Application.CommandBars("Standard").Controls(1).Enabled = False
Application.CommandBars("Standard").Controls(2).Enabled = False
'Application.CommandBars("Standard").Controls(3).Enabled = True
Application.CommandBars("Standard").Controls(9).Enabled = False
Application.CommandBars("Standard").Controls(10).Enabled = False
Application.CommandBars("Standard").Controls(11).Enabled = False

' turn off shortcutkeys:
Application.OnKey "^c", ""
Application.OnKey "^v", ""
Application.OnKey "^x", ""

End Sub

Sub FullNameInRightFooter()

ActiveSheet.PageSetup.RightFooter = ActiveWorkbook.FullName

End Sub

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox "Right Click Disabled."
End Sub
====================================================
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I think you could use these events


Private Sub Workbook_WindowActivate(ByVal Wn As Window)
in order to set your default

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
in order to set excel default for other files

DM
 
Upvote 0
Thanks DM,


That Works Excellent for me.

And That was very Quick indeed.

However one small thing left out....Disabling Commands on Insert Menu.


Any help on that?

Thank
Tanmay.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,331
Members
449,077
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top