Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Excell copy action pauses for 15 second for the smallest action Meekal Excel Discussion (Misc queries) 1 January 28th 10 04:30 PM
rewrite in range ina Excel Programming 2 May 16th 06 03:07 PM
How can I rewrite this using an Array? Fred[_21_] Excel Programming 7 September 13th 05 05:45 PM
Custom Toolbar: ListBox on.action not working Alison[_3_] Excel Programming 3 August 11th 04 04:30 AM


All times are GMT +1. The time now is 12:09 AM.

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"