Disabling right-click on sheet tab on ONLY one workbook

mcomp72

Active Member
Joined
Aug 14, 2016
Messages
275
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2011
Platform
  1. Windows
  2. MacOS
I would like to disable the ability for the user to right-click on any of the sheet tabs in a particular workbook. I ran across a web page that talked about how to do it, using this code in the ThisWorkbook module:

Code:
<code class="vb keyword">
Private</code> <code class="vb keyword">Sub</code> <code class="vb plain">Workbook_BeforeClose(Cancel </code><code class="vb keyword">As</code> <code class="vb keyword">Boolean</code><code class="vb plain">)</code><code class="vb spaces">
</code><code class="vb plain">
   Application.CommandBars(</code><code class="vb string">"Ply"</code><code class="vb plain">).Enabled = </code><code class="vb keyword">True</code>

<code class="vb keyword">End</code> <code class="vb keyword">Sub</code>
  

<code class="vb keyword">Private</code> <code class="vb keyword">Sub</code> <code class="vb plain">Workbook_Open()</code>

<code class="vb spaces">    </code><code class="vb plain">Application.CommandBars(</code><code class="vb string">"Ply"</code><code class="vb plain">).Enabled = </code><code class="vb keyword">False</code>

<code class="vb keyword">End</code> <code class="vb keyword">Sub</code>

This works. HOWEVER, if I am running the workbook in question with this code inside, and then I open ANOTHER workbook, the right-click is disabled on that workbook, also. I ONLY want it to be disabled on the one workbook that has the above code in it. How can I do that?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Add these :
Code:
Private Sub Workbook_Activate()
Application.CommandBars("Ply").Enabled = False
End Sub


Private Sub Workbook_Deactivate()
Application.CommandBars("Ply").Enabled = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top