PPT: How to Create a PowerPoint 97 Add-InLast reviewed: March 9, 1998Article ID: Q163461 |
The information in this article applies to:
SUMMARYThis article describes how to create an add-in for Microsoft PowerPoint using Microsoft Visual Basic for Applications. The sample macro (Sub procedure) adds a command to the Tools menu to allow you to change your view to slide sorter view if you are not already in slide sorter view.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and 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 needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/default.asp Step 1 - Create the Code for the Add-In
Step 2 - Create the Auto_Open MacroThe Auto_Open macro stores initialization code for your add-in and it is automatically executed when the add-in is loaded by PowerPoint. The following code, adds a command (Change to Slide Sorter) to the Tools menu that executes your add-in code.
Sub Auto_Open() Dim NewControl As CommandBarControl ' Store an object reference to a command bar. Dim ToolsMenu As CommandBars ' Figure out where to place the menu choice. Set ToolsMenu = Application.CommandBars ' Create the menu choice. The choice is created in the first ' position in the Tools menu. Set NewControl = ToolsMenu("Tools").Controls.Add _ (Type:=msoControlButton, _ Before:=1) ' Name the command. NewControl.Caption = "Change to Slide Sorter" ' Connect the menu choice to your macro. The OnAction property ' should be set to the name of your macro. NewControl.OnAction = "ChangeView" End Sub Step 3 - Create the Auto_Close MacroThe Auto_Close macro is executed when an add-in is unloaded by PowerPoint. The Auto_Close macro stores your clean-up code. The following code removes the command you added to the Tools menu in the "Create the Auto_Open Macro" section of this article.
Sub Auto_Close() Dim oControl As CommandBarControl Dim ToolsMenu As CommandBars ' Get an object reference to a command bar. Set ToolsMenu = Application.CommandBars ' Loop through the commands on the tools menu. For Each oControl In ToolsMenu("Tools").Controls ' Check to see whether the comand exists. If oControl.Caption = "Change to Slide Sorter" Then ' Check to see whether action setting is set to ChangeView. If oControl.OnAction = "ChangeView" Then ' Remove the command from the menu. oControl.Delete End If End If Next oControl End Sub Step 4 - Create the .ppa File
Step 5 - Load the Add-In
NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Visual Basic Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q120802 TITLE : Office: How to Add/Remove a Single Office Program or Component Step 6 - Unload the Add-InUse the following steps to unload an add-in:
NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Visual Basic Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q120802 TITLE : Office: How to Add/Remove a Single Office Program or Component Step 7 - Protecting Your Add-In with a PasswordWhen you save a presentation as an add-in, PowerPoint does not protect your source code. You can protect your code with a password, using the following steps. NOTE: You must protect your project with a password before you save the add-in.
REFERENCESFor more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q163435 TITLE : VBA: Programming Resources for Visual Basic for Applications |
Additional query words: 8.00 ppt8 vba vbe addin addins macppt mac_ppt ppt98
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |