Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Disable a new paste button

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Disable a new paste button

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Disable a new paste button

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Disable a new paste button

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" wrote in message
...
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
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
Disable Close Button dan Excel Discussion (Misc queries) 5 September 22nd 06 07:39 PM
Disable Button Pete JM[_3_] Excel Programming 2 April 12th 04 01:04 PM
how do you disable a button? jest[_4_] Excel Programming 1 March 4th 04 01:05 PM
Disable the right mouse button?? Richard m Excel Programming 1 December 7th 03 03:48 AM
Disable Button Pete[_12_] Excel Programming 3 October 8th 03 01:30 PM


All times are GMT +1. The time now is 08:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"