Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 15th, 2007, 08:38 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default Mouse right-click inoperable

Hi,

I have disabled various User functions within a specified Workbook, depending on the User.

A couple of examples are:

'Prevent Right-Click on WorkSheet Tab
Code:
Application.CommandBars("PLY").Enabled = False
'Prevent Right-Click on WorkSheet Cells
Code:
Application.CommandBars("CELL").Enabled = False
The problem is that one user claims that he is now unable to 'Right Click' on Cells in OTHER Excel workbooks.

Does anyone know how to resolve this? i.e. To limit the restrictions to the specific Workbook?

Thanks in advance,





Neal

A Northern Soul
__________________
Neal

A Northern Soul
 
Old March 15th, 2007, 02:04 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Not sure why you want to cancel Right-Click but you should trap it from the spreadsheet instead:

--------------------------------------------------------------------------------------------------

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

'Cancels Right Click for this worksheet
  Cancel = True

End Sub
--------------------------------------------------------------------------------------------------

You could also check ranges this way and only cancel the Right-Click for certain cells or cell values or cell states (etc, etc).

 
Old March 16th, 2007, 05:32 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default

I have been advised of the following code.

On current/active workbook:

Code:
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
'Prevent Right-Click on WorkSheet Tab
Application.CommandBars("PLY").Enabled = False

'Prevent Right-Click on WorkSheet Cells
Application.CommandBars("CELL").Enabled = False
End Sub
When accessing Other opened workbooks:

Code:
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
'Allow Right-Click on WorkSheet Tab
Application.CommandBars("PLY").Enabled = True

'Allow Right-Click on WorkSheet Cells
Application.CommandBars("CELL").Enabled = True
End Sub
which appears to work.

Thanks..


Neal

A Northern Soul





Similar Threads
Thread Thread Starter Forum Replies Last Post
determine mouse click position amr_qura Struts 0 June 26th, 2007 03:40 PM
right click mouse event sen22 ASP.NET 2.0 Basics 5 December 16th, 2006 08:46 AM
Capturing Mouse Click Event whiterainbow ASP.NET 1.0 and 1.1 Professional 1 December 8th, 2005 01:44 AM
detect mouse click off form vb certified Beginning VB 6 6 July 7th, 2005 07:55 PM
Mouse Click Event roniestein Access 4 December 11th, 2003 04:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.