Difference between revisions of "Main Page/Stuff/PowerPoint Add-ins/instructions"
Phil Hurvitz (talk | contribs) (New page: From [http://support.microsoft.com/kb/q222737/ http://support.microsoft.com/kb/q222737/] United States Change | All Microsoft Sites Microsoft Help and Support powered byLive Search ...) |
Phil Hurvitz (talk | contribs) |
(No difference)
|
Latest revision as of 00:23, 6 March 2009
From http://support.microsoft.com/kb/q222737/
United States Change | All Microsoft Sites Microsoft Help and Support
powered byLive Search
* Help and Support Home * * Select a Product * * Advanced Search
Article ID: 222737 - Last Review: October 11, 2006 - Revision: 2.2 How to create a PowerPoint add-in in PowerPoint 2000 View products that this article applies to. This article was previously published under Q222737 For a Microsoft PowerPoint 97 version of this article, see 163461 (http://support.microsoft.com/kb/163461/ ) . On This Page
* SUMMARY * MORE INFORMATION o Step 1 - Create the Code for the Add-In o Step 2 - Create the Auto_Open Macro o Step 3 - Create the Auto_Close Macro o Step 4 - Create the .ppa File o Step 5 - Load the Add-In o Step 6 - Unload the Add-In o Step 7 - Protecting Your Add-In with a Password * REFERENCES
Expand all | Collapse all SUMMARY This article describes how to create an add-in for Microsoft PowerPoint using M... This 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. Back to the top MORE INFORMATION Microsoft provides programming examples for illustration only, without warranty... 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. NOTE: The following macro examples work only in PowerPoint. Visual Basic for Applications macros are not supported by the Microsoft PowerPoint Viewer. For additional information, click the following article number to view the article in the Microsoft Knowledge Base: Back to the top Step 1 - Create the Code for the Add-In
To create the code for the add-in, follow these steps:
1. Start PowerPoint and create a blank presentation. 2. On the Tools menu, point to Macro, and then click Visual Basic Editor. 3. In the Visual Basic Editor, click Module, on the Insert menu. 4. Type the following code in the Module window. NOTE: You can substitute your code for the following code.
Sub ChangeView()
' Check to see whether a presentation is open. If Presentations.Count <> 0 Then If ActiveWindow.ViewType <> ppViewSlideSorter Then ActiveWindow.ViewType = ppViewSlideSorter End If Else MsgBox "No presentation open. Open a presentation and " _ & "run the macro again.", vbExclamation End If End Sub
NOTE: A line that is preceded by an apostrophe (') introduces a comment in the code. Comments are provided to explain what the code is doing at a particular point in the procedure. This text is optional and may be excluded from your code.
Back to the top Step 2 - Create the Auto_Open Macro The 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
Back to the top
Step 3 - Create the Auto_Close Macro
The 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 that 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
Back to the top
Step 4 - Create the .ppa File
To create the .ppa file, follow these steps:
1. On the Debug menu, click Compile VBAProject. If your code has compile errors, you will not be able to create the add-in. NOTE: This step is only required if the Auto Syntax Check option in the Visual Basic Editor is not selected. To turn this option on or off, follow these steps: 1. Click Options on the Tools menu, and then click the Editor tab. 2. Click to clear or select the Auto Syntax Check check box, and then click OK. If this option is currently selected, skip to step 2. 2. Save the presentation. 1. On the File menu, click Close and Return to Microsoft PowerPoint. 2. On the File menu, click Save As. 3. Select Presentation (*.ppt) in the Save As Type list. 4. Name the presentation, and then click Save. Your add-in code is now saved in the presentation. 3. Create the .ppa file. 1. On the File menu, click Save As. 2. Select PowerPoint Add-In (*.ppa) in the Save As Type list. 3. In the File Name box, type a name for your add-in, and then click Save. Typically, PowerPoint add-ins are placed in the c:\Program Files\ Microsoft Office\Office folder. However, you can choose another folder if you want.
Back to the top Step 5 - Load the Add-In To load the add-in, follow these steps:
1. On the Tools menu, click Add-Ins. 2. Click Add New. 3. In the Add New PowerPoint Add-In dialog box, select the add-in file you created in the "Step 4 - Create the PPA File" section. Click OK. 4. In the macro warning message box, click Enable Macros.
NOTE: If you received an add-in file from an unknown source, you should click Disable Macros.
The Auto_Open macro now executes.
For information about how to use the PowerPoint object model to load add-ins, click the Office Assistant, type loaded property, click Search, and then click to view Loaded Property.
For additional information, click the article number below to view the article in the Microsoft Knowledge Base: 222685 (http://support.microsoft.com/kb/222685/EN-US/ ) PPT2000: How to Auto Load a PowerPoint Add-In Back to the top Step 6 - Unload the Add-In To unload an add-in, follow these steps :
1. On the Tools menu, click Add-Ins. 2. From the Available Add-Ins list, select the add-in you want to unload, and then click Unload or Remove. When you click Unload, the add-in is unloaded but it remains on the Available Add-Ins list. When you click Remove, the add-in is unloaded and it is removed from the Available Add-Ins list.
The Auto_Close macro now executes.
Back to the top Step 7 - Protecting Your Add-In with a Password When you save a presentation as an add-in, PowerPoint does not protect your source code. You can protect your code with a password. To do this, follow these steps:
NOTE: You must protect your project with a password before you save the add-in.
1. On the Tools menu, click VBAProject Properties, and then click the Protection tab. 2. Click to select the Lock Project For Viewing check box. 3. Under Password To View Project Properties, type the password you want in the Password and Confirm Password boxes. 4. Click OK. A password is now required to view your source code.
Back to the top REFERENCES For more information about how to use the sample code in this article, click th... For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base: 212536 (http://support.microsoft.com/kb/212536/EN-US/ ) OFF2000: How to Run Sample Code from Knowledge Base Articles Back to the top APPLIES TO
* Microsoft PowerPoint 2000 Standard Edition
Back to the top Keywords: kbautomation kbvba kbaddin kbcode kbdtacode kbhowto kbmacro kbprogramming KB222737 Back to the top
Provide feedback on this information Did this information solve your problem? Yes No I don't know Was this information relevant? Yes No What can we do to improve this information? To protect your privacy, do not include contact information in your feedback.
Thank you! Your feedback is used to help us improve our support content. For more assistance options, please visit the Help and Support Home Page.
Get Help Now Contact a support professional by E-mail, Online, or Phone Article Translations
Related Support Centers
* PowerPoint 2000
Page Tools
* Print this page * E-mail this page
Get Help Now
Contact a support professional by E-mail, Online, or Phone
Help and Support
Services Agreement
Contact Us | Terms of Use | Trademarks | Privacy Statement
Microsoft Microsoft ©2009 Microsoft