Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Customizing Shortcut Menus

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
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
Customizing Menus in Excel 2007 Loris Excel Discussion (Misc queries) 1 February 11th 08 10:52 PM
Right-Click Menus - Customizing s boak Excel Discussion (Misc queries) 6 October 9th 06 08:04 PM
Prevent user from customizing menus in Excel. Tim Marsden[_2_] Excel Programming 2 November 24th 05 07:48 AM
Customizing popup menus VanS[_2_] Excel Programming 3 March 14th 05 01:33 PM
Customizing popup menus VanS Excel Discussion (Misc queries) 5 March 14th 05 01:27 PM


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

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"