Microsoft KB Archive/170563: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
Line 58: Line 58:
The following Visual Basic for Applications subroutine turns off (disables) the '''Toolbar List''' shortcut menu:
The following Visual Basic for Applications subroutine turns off (disables) the '''Toolbar List''' shortcut menu:
<pre class="codesample">  Sub DisableToolbarMenu()
<pre class="codesample">  Sub DisableToolbarMenu()
       CommandBars(&quot;Toolbar List&quot;).Enabled = False
       CommandBars("Toolbar List").Enabled = False
   End Sub
   End Sub
                 </pre>
                 </pre>
Line 65: Line 65:
The following subroutine turns on (enables) the '''Toolbar List''' shortcut menu:
The following subroutine turns on (enables) the '''Toolbar List''' shortcut menu:
<pre class="codesample">  Sub EnableToolbarMenu()
<pre class="codesample">  Sub EnableToolbarMenu()
       CommandBars(&quot;Toolbar List&quot;).Enabled = True
       CommandBars("Toolbar List").Enabled = True
   End Sub
   End Sub
                 </pre>
                 </pre>
Line 74: Line 74:
The following sample subroutine turns off the '''Toolbar List''' shortcut menu and deletes the '''Customize''' menu option, which prevents others from modifying the menus and toolbars in a custom application:
The following sample subroutine turns off the '''Toolbar List''' shortcut menu and deletes the '''Customize''' menu option, which prevents others from modifying the menus and toolbars in a custom application:
<pre class="codesample">  Sub DisableCustomize()
<pre class="codesample">  Sub DisableCustomize()
         Application.CommandBars(&quot;Tools&quot;).Controls(&quot;&amp;Customize...&quot;).Delete
         Application.CommandBars("Tools").Controls("&amp;Customize...").Delete
         CommandBars(&quot;Toolbar List&quot;).Enabled = False
         CommandBars("Toolbar List").Enabled = False
   End Sub
   End Sub
                 </pre>
                 </pre>
You can use the following subroutine to restore the '''Customize''' menu command and allow others to display the '''Toolbar List''' shortcut menu:
You can use the following subroutine to restore the '''Customize''' menu command and allow others to display the '''Toolbar List''' shortcut menu:
<pre class="codesample">  Sub EnableCustomize()
<pre class="codesample">  Sub EnableCustomize()
       Application.CommandBars(&quot;Tools&quot;).Controls.Add _
       Application.CommandBars("Tools").Controls.Add _
               Type:=msoControlButton, Id:=797, Before:=13
               Type:=msoControlButton, Id:=797, Before:=13
       CommandBars(&quot;Toolbar List&quot;).Enabled = True
       CommandBars("Toolbar List").Enabled = True
   End Sub
   End Sub
                 </pre>
                 </pre>
Line 91: Line 91:
== REFERENCES ==
== REFERENCES ==


For more information about customizing command bars, click the Office Assistant in the Visual Basic Editor, type <span class="kbd userinput"> commandbars</span>, click Search, and then click to view &quot;Using command bars&quot;.<br />
For more information about customizing command bars, click the Office Assistant in the Visual Basic Editor, type <span class="kbd userinput"> commandbars</span>, click Search, and then click to view "Using command bars".<br />
<br />
<br />
'''Note''' If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:
'''Note''' If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

Revision as of 11:04, 21 July 2020

Article ID: 170563

Article Last Modified on 10/11/2006



APPLIES TO

  • Microsoft PowerPoint 97 Standard Edition
  • Microsoft Excel 97 Standard Edition
  • Microsoft Word 97 Service Pack 1



This article was previously published under Q170563

SUMMARY

In Microsoft Office 97, Service Release 1 (SR-1), the CommandBars object model allows you to turn off (disable) the Toolbars shortcut menu. This simplifies preventing others from changing the toolbars and menus of a custom application that you develop with Microsoft Office 97.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Turning the Toolbar Shortcut Menu On and Off

The following Visual Basic for Applications subroutine turns off (disables) the Toolbar List shortcut menu:

   Sub DisableToolbarMenu()
       CommandBars("Toolbar List").Enabled = False
   End Sub
                

After you run this subroutine, the Toolbars command on the View menu is unavailable. Also, you cannot display a list of available toolbars by pointing to and then right-clicking a toolbar.

The following subroutine turns on (enables) the Toolbar List shortcut menu:

   Sub EnableToolbarMenu()
       CommandBars("Toolbar List").Enabled = True
   End Sub
                

Preventing Users from Changing Menus and Toolbars

Setting the Visible property of the Toolbar List shortcut menu does not prevent others from making changes to the menus and toolbars of a custom application. To prevent others from changing the menus and toolbars in a custom application, remove or turn off the Customize option on the Tools menu and turn off the Toolbar List shortcut menu.

The following sample subroutine turns off the Toolbar List shortcut menu and deletes the Customize menu option, which prevents others from modifying the menus and toolbars in a custom application:

   Sub DisableCustomize()
        Application.CommandBars("Tools").Controls("&Customize...").Delete
        CommandBars("Toolbar List").Enabled = False
   End Sub
                

You can use the following subroutine to restore the Customize menu command and allow others to display the Toolbar List shortcut menu:

   Sub EnableCustomize()
       Application.CommandBars("Tools").Controls.Add _
               Type:=msoControlButton, Id:=797, Before:=13
       CommandBars("Toolbar List").Enabled = True
   End Sub
                

REFERENCES

For more information about customizing command bars, click the Office Assistant in the Visual Basic Editor, type commandbars, click Search, and then click to view "Using command bars".

Note If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

120802 Office: How to Add/Remove a Single Office Program or Component



Additional query words: xlvbainfo

Keywords: kbinfo kbinterop kbprogramming KB170563