![]() |
Rewrite cut action not working.
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 |
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 |
Rewrite cut action not working.
If I changed Activeworkbook to Application, it seemed to work ok.
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 -- Dave Peterson |
All times are GMT +1. The time now is 12:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com