Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to disable or enable the Delete command of the edit menu based on what
is currently selected on a worksheet. I put the following code in the Selection Change event of the worksheet that I want to control. The code works perfectly to disable the command on the edit menu. Unfortunately, I get a run-time error (Error 5: Invalid Procedure Call or argument) when I try to enable the command. Why would the code work properly on the first line and generate an error on the second line? I would greatly appreciate any help determining what is going on with my spreadsheet. Mary Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'PREVENT USER FROM DELETING COLUMNS If Selection.Address = Target.EntireColumn.Address Then Application.CommandBars("worksheet menu bar").Controls("edit").Controls("delete").Enabled = False Else: IsFormulaCardOpen 'CANNOT FIGURE OUT WHY THIS LINE DOES NOT WORK TO REACTIVATE MENU OPTION If OpenFC = False Then _ Application.CommandBars("worksheet menu bar").Controls("edit").Controls("delete").Enabled = True End If End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mary,
Try changing "delete" to "delete..." Regards, Peter T "Mary" wrote in message ... I want to disable or enable the Delete command of the edit menu based on what is currently selected on a worksheet. I put the following code in the Selection Change event of the worksheet that I want to control. The code works perfectly to disable the command on the edit menu. Unfortunately, I get a run-time error (Error 5: Invalid Procedure Call or argument) when I try to enable the command. Why would the code work properly on the first line and generate an error on the second line? I would greatly appreciate any help determining what is going on with my spreadsheet. Mary Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'PREVENT USER FROM DELETING COLUMNS If Selection.Address = Target.EntireColumn.Address Then Application.CommandBars("worksheet menu bar").Controls("edit").Controls("delete").Enabled = False Else: IsFormulaCardOpen 'CANNOT FIGURE OUT WHY THIS LINE DOES NOT WORK TO REACTIVATE MENU OPTION If OpenFC = False Then _ Application.CommandBars("worksheet menu bar").Controls("edit").Controls("delete").Enabled = True End If End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you. It works now.
"Peter T" wrote: Hi Mary, Try changing "delete" to "delete..." Regards, Peter T "Mary" wrote in message ... I want to disable or enable the Delete command of the edit menu based on what is currently selected on a worksheet. I put the following code in the Selection Change event of the worksheet that I want to control. The code works perfectly to disable the command on the edit menu. Unfortunately, I get a run-time error (Error 5: Invalid Procedure Call or argument) when I try to enable the command. Why would the code work properly on the first line and generate an error on the second line? I would greatly appreciate any help determining what is going on with my spreadsheet. Mary Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'PREVENT USER FROM DELETING COLUMNS If Selection.Address = Target.EntireColumn.Address Then Application.CommandBars("worksheet menu bar").Controls("edit").Controls("delete").Enabled = False Else: IsFormulaCardOpen 'CANNOT FIGURE OUT WHY THIS LINE DOES NOT WORK TO REACTIVATE MENU OPTION If OpenFC = False Then _ Application.CommandBars("worksheet menu bar").Controls("edit").Controls("delete").Enabled = True End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
enable Right-click menu | Excel Worksheet Functions | |||
Enable Command Button Procedure | Excel Discussion (Misc queries) | |||
Replace menu command not working | Excel Discussion (Misc queries) | |||
Where is menu option to enable macros? | Excel Discussion (Misc queries) | |||
Enable Command Button 1 & 2 | Excel Programming |