PC Review


Reply
Thread Tools Rate Thread

Customizing Shortcut Menus

 
 
mooresk257
Guest
Posts: n/a
 
      2nd Jun 2010
I have this code to control user access to commands:

Private Sub Workbook_WindowActivate(ByVal Wn As Window)

Dim Cmdbar As CommandBar
For Each Cmdbar In Application.CommandBars
Cmdbar.Enabled = False
Next

Application.CommandBars("Cell").Enabled = True

Application.DisplayStatusBar = True
Application.DisplayPasteOptions = True
Application.CutCopyMode = True

With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
End With

End Sub

I want to restrict right-click menu options to Cut, Copy, and Paste -
specifically paste as values. I've been trying the suggestions I've found for
code solutions related to pop-ups in the VBA help files, and on the MSFT KB,
but I keep getting function errors. This code seems like it would be the
solution but I'm not sure why it is not working:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)

Set copyAndPasteMenu = CommandBars.Add(Name:="Custom",
Position:=msoBarPopup, Temporary:=True)
Set Copy = copyAndPasteMenu.Controls.Add
With Copy
.FaceId = CommandBars("Standard").Controls("Copy").ID
.Caption = "Copy the selection"
End With
Set Paste = copyAndPasteMenu.Controls.Add
With Paste
.FaceId = CommandBars("Standard").Controls("Paste").ID
.Caption = "Paste from the Clipboard"
End With
copyAndPasteMenu.ShowPopup 200, 200

End Sub

Any suggestions?

Thanks,

Scott
 
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
Right-Click Menus - Customizing s boak Microsoft Excel Misc 6 9th Oct 2006 08:04 PM
Customizing popup menus =?Utf-8?B?VmFuUw==?= Microsoft Excel Misc 5 14th Mar 2005 01:27 PM
Customizing quick menus =?Utf-8?B?ZGFubmx5bm4=?= Windows XP General 1 25th Dec 2004 03:31 PM
Customizing Context Menus =?Utf-8?B?VGhvcm91Z2hseSBDb25mdXNlZA==?= Windows XP General 1 26th Nov 2004 06:20 AM
Customizing Menus April Windows XP Customization 1 19th Aug 2004 07:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:06 AM.