View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Rewrite cut action not working.

The command bars you are accessing are part of the Application and not part
of the ActiveWorkBook. So you would need to use something more like...

Sub mycut()
Application.CommandBars("Standard").Controls("Cut" ).OnAction = "MyCopy"
Application.CommandBars("Cell").Controls("cut").On Action = "MyCopy"
End Sub

Note that this means that you are effecting the eay that the XL application
works and not just how the active workbook works. All spreadsheet open will
be effected by this code...
--
HTH...

Jim Thomlinson


"KS" wrote:

Why isn't this working? I get an "object variable or with block not
set" error.



Sub MyCopy()
'rewrite Ctrl-X
Selection.Copy
MsgBox "Please copy [Ctrl-C] rather than cut."
End Sub



Sub mycut()
ActiveWorkbook.CommandBars("Standard").Controls("C ut").OnAction =
"MyCopy"
ActiveWorkbook.CommandBars("Cell").Controls("cut") .OnAction =
"MyCopy"

End Sub