Thread: Copy ... Paste
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default Copy ... Paste

"Ernst Guckel" wrote in message
...
Is there a way to test for data to be pasted?

I have a rightclick menu item 'Paste Values' to replace 'Paste' but I
want to grey it out when there is no data to be pasted. And enable it
back
when there is data available to be pasted. Any help would be great...


Hi Ernst,

In this particular case, the easiest thing to do would be to have Excel
handle this for you automatically. There is a built-in Paste Values command
bar control you can add to your menu that will be enabled/disabled
appropriately based on whether there is data in the clipboard. You can add
this control to your CommandBar using its ID number 370, like so:

Dim ctlMenu As CommandBarButton
Set ctlMenu = CommandBars("MyBar").Controls.Add(ID:=370)
ctlMenu.Style = msoButtonIconAndCaption

There is no need to assign a macro to this control, since it already knows
how to perform a paste special values.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm