Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 190
Default enable menu command not working

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default enable menu command not working

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 190
Default enable menu command not working

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
enable Right-click menu Saleh Excel Worksheet Functions 2 June 24th 08 01:37 AM
Enable Command Button Procedure Kenny Excel Discussion (Misc queries) 1 October 14th 07 03:09 AM
Replace menu command not working RS Excel Discussion (Misc queries) 2 January 29th 07 05:57 PM
Where is menu option to enable macros? dc1995 Excel Discussion (Misc queries) 1 January 19th 06 08:01 PM
Enable Command Button 1 & 2 Mikeice[_20_] Excel Programming 3 June 17th 05 06:00 AM


All times are GMT +1. The time now is 09:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"