View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan[_2_] Rowan[_2_] is offline
external usenet poster
 
Posts: 226
Default How can enable and disable menuitems based on the type of sheet.

Use the sheet activate / deactivate events. This example disables the
DataSort command. This is worksheet code: right click the sheet tab, select
view code and paste the code. Do this for each of the three sheets changing
the menu and control names so that the relevant menu items are disabled for
each sheet.

Private Sub Worksheet_Activate()
CommandBars(1).Controls("Data").Controls("Sort..." ).Enabled = False
End Sub


Private Sub Worksheet_Deactivate()
CommandBars(1).Controls("Data").Controls("Sort..." ).Enabled = True
End Sub

Hope this helps
Rowan

"shishi" wrote:

Hi,

First of all I thank Tom, Bernie and Norman for responding to my
posts in this group. Your responses helped me to wrap up the small
project that I am doing in excel. As a last task I am now doing a menu
for this project.I have created the menu and added it to the excel
file. The menu appears right before the help menu. The menu gets added
to the workbook when we open it. There are three sheets in this
workbook. But all the menuitems will not operate on all the three
sheets. Some work on first, some work on second, some work on third.
How can I disable the menuitems based on the sheet name. Thanks in
advance for all the help.

Shishi