PC Review


Reply
Thread Tools Rate Thread

Disable a new paste button

 
 
=?Utf-8?B?QmFzaWw=?=
Guest
Posts: n/a
 
      13th Oct 2006
Hi,

I've created a new button for my toolbar - 'Paste Formulas'.
Code behind it is:
If Application.CutCopyMode = False Then
Exit Sub
Else
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
End If

When Excel is not in cutcopymode, the regular paste button is disabled. Is
there any way I can do this for my paste formulas button too?

I'd rather not do this on a 'worksheet_change' sub or anything that will
slow up excel.

Any tips would be appreciated,

Basil

 
Reply With Quote
 
 
 
 
Sandy
Guest
Posts: n/a
 
      13th Oct 2006
See if this works.

If Application.CutCopyMode = False Then
Application.CommandBars("What bar it's on"). _
Controls.Item("Your button").Enabled = False
Exit Sub
Else
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
End If


Sandy

Basil wrote:
> Hi,
>
> I've created a new button for my toolbar - 'Paste Formulas'.
> Code behind it is:
> If Application.CutCopyMode = False Then
> Exit Sub
> Else
> Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
> SkipBlanks:= _
> False, Transpose:=False
> End If
>
> When Excel is not in cutcopymode, the regular paste button is disabled. Is
> there any way I can do this for my paste formulas button too?
>
> I'd rather not do this on a 'worksheet_change' sub or anything that will
> slow up excel.
>
> Any tips would be appreciated,
>
> Basil


 
Reply With Quote
 
=?Utf-8?B?QmFzaWw=?=
Guest
Posts: n/a
 
      14th Oct 2006
Thanks Sandy. Nothing wrong with the code, but this will only disable it
after it is clicked.

I want it to behave exactly the same as the paste button (i.e. is disabled
all the time unless cutcopymode is true).

Is there a way that I can get Excel to run the code only when something is
copied into the clipboard?

Thanks.

B

"Sandy" wrote:

> See if this works.
>
> If Application.CutCopyMode = False Then
> Application.CommandBars("What bar it's on"). _
> Controls.Item("Your button").Enabled = False
> Exit Sub
> Else
> Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
> SkipBlanks:= _
> False, Transpose:=False
> End If
>
>
> Sandy
>
> Basil wrote:
> > Hi,
> >
> > I've created a new button for my toolbar - 'Paste Formulas'.
> > Code behind it is:
> > If Application.CutCopyMode = False Then
> > Exit Sub
> > Else
> > Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
> > SkipBlanks:= _
> > False, Transpose:=False
> > End If
> >
> > When Excel is not in cutcopymode, the regular paste button is disabled. Is
> > there any way I can do this for my paste formulas button too?
> >
> > I'd rather not do this on a 'worksheet_change' sub or anything that will
> > slow up excel.
> >
> > Any tips would be appreciated,
> >
> > Basil

>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      16th Oct 2006
Basil,
You can add code to the top level menu to check the value of
Application.CutCopyMode and toggle the .Enabled property of your lower menu
item accordingly
This code must run in order to create the menu tree, so check then.

MainMenu.OnAction = "MainMenu_Click"

Public Function MainMenu_Click()
MsgBox Application.CutCopyMode
'Set the .Enabled property of your "Paste Formulas" menu item accordingly
End Function

NickHK

"Basil" <(E-Mail Removed)> wrote in message
news:10966257-43DB-480C-A54F-(E-Mail Removed)...
> Thanks Sandy. Nothing wrong with the code, but this will only disable it
> after it is clicked.
>
> I want it to behave exactly the same as the paste button (i.e. is disabled
> all the time unless cutcopymode is true).
>
> Is there a way that I can get Excel to run the code only when something is
> copied into the clipboard?
>
> Thanks.
>
> B
>
> "Sandy" wrote:
>
> > See if this works.
> >
> > If Application.CutCopyMode = False Then
> > Application.CommandBars("What bar it's on"). _
> > Controls.Item("Your button").Enabled = False
> > Exit Sub
> > Else
> > Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
> > SkipBlanks:= _
> > False, Transpose:=False
> > End If
> >
> >
> > Sandy
> >
> > Basil wrote:
> > > Hi,
> > >
> > > I've created a new button for my toolbar - 'Paste Formulas'.
> > > Code behind it is:
> > > If Application.CutCopyMode = False Then
> > > Exit Sub
> > > Else
> > > Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
> > > SkipBlanks:= _
> > > False, Transpose:=False
> > > End If
> > >
> > > When Excel is not in cutcopymode, the regular paste button is

disabled. Is
> > > there any way I can do this for my paste formulas button too?
> > >
> > > I'd rather not do this on a 'worksheet_change' sub or anything that

will
> > > slow up excel.
> > >
> > > Any tips would be appreciated,
> > >
> > > Basil

> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i disable copy/paste button through macro in c# =?Utf-8?B?c3VuaWw=?= Microsoft Word Document Management 1 5th Apr 2007 06:59 PM
Skin pocket pc, disable hardware buttons, disable start button Tizio Incognito Microsoft Dot NET Compact Framework 1 3rd Feb 2005 09:13 AM
Paste button greyed out So I can Not not paste between Excel =?Utf-8?B?Ym9i?= Microsoft Excel Programming 0 21st Apr 2004 12:36 AM
Paste Options Button Does Not Appear When You Paste Between Two Instances of Exc Robert Microsoft Excel Programming 0 6th Apr 2004 11:32 PM
How to Disable a Button from the Button's Event Handler? Jay Chan Microsoft Access 3 12th Nov 2003 03:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:49 AM.