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:
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?
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?