Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excell copy action pauses for 15 second for the smallest action | Excel Discussion (Misc queries) | |||
rewrite in range | Excel Programming | |||
How can I rewrite this using an Array? | Excel Programming | |||
Custom Toolbar: ListBox on.action not working | Excel Programming |