Microsoft Knowledge Base

PPT97: How to Run Sample Code from Knowledge Base Articles

Last reviewed: June 12, 1997
Article ID: Q162100
The information in this article applies to:
  • Microsoft PowerPoint 97 for Windows

SUMMARY

The Microsoft Knowledge Base contains a number of articles that contain sample code for PowerPoint 97 macros. These macros illustrate basic concepts for programming PowerPoint 97. This article contains instructions on how to use the sample code to create a new macro, and how to run that macro.

MORE INFORMATION

PowerPoint stores macros in presentations. To use the sample code in a Knowledge Base article, you must add a new (or select an existing) Visual Basic for Applications module in a presentation. You can then paste or type the sample code into this module.

To Create or Select a Module in a Presentation

  1. Start PowerPoint and create a new presentation (or open an existing one.)

  2. On the Tools menu, point to Macro and then click Visual Basic Editor.

  3. In the Project window (by default this is in the upper left corner of the Visual Basic Editor), click the VBAProject that has the same name as your presentation. If you haven't yet saved your presentation, it will be called something similar to VBAProject(Presentation1).

  4. If the VBAProject you clicked doesn't have a folder called Modules displayed beneath it, click Module on the Insert menu.

To Add the Sample Code to the Module from the Clipboard

  1. In the program that you are using to view the Knowledge Base article (such as Microsoft Internet Explorer), select the sample code by dragging your mouse across it. The sample code in Knowledge Base articles typically begins with the text:

          Sub <macro name>()
    
       and ends with the text:
    
          End Sub
    
    

  2. On the Edit menu, click Copy.

  3. Switch to the Visual Basic Editor. If the Visual Basic editor is not currently running, follow the steps listed above to open it.

  4. On the Edit menu, click Paste.

To Add the Sample Code to the Module Yourself

  1. Click anywhere in the code window of the Visual Basic Editor. The code Window is usually in the upper right corner of the Visual Basic Editor.

  2. Type the sample code exactly as it appears in the Knowledge Base article. You can use the Tab key to indent text. Lines that begin with an apostrophe (') are comments and are not required to run the macro. However, you may want to type them in anyway to make it easier to modify the macro later.

To Run the Macro

  1. Switch from the Visual Basic Editor to your PowerPoint presentation.

  2. On the Tools menu, point to Macro and then click Macros.

  3. Click the name of the macro on the Macro Name list and then click Run.

NOTE: There are other ways to run PowerPoint macros. You can run macros directly from the Visual Basic Editor, from a PowerPoint Slide Show by applying the macro as an Action Setting to a graphic, or by adding an ActiveX control to a slide or Visual Basic form.

Microsoft provides examples of Visual Basic for Applications procedures 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.

The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs.

If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

REFERENCES

PowerPoint Help contains numerous topics about working with macros. Visual Basic help contains extensive information about writing your own code.


Additional query words: 97 8.00 ppt8 vba vbe visual basic
Keywords : kbpptvba kbprg
Version : 97
Platform : WINDOWS
Issue type : kbhowto
Resolution Type : kbcode


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 12, 1997
©1997 Microsoft Corporation. All rights reserved. Legal Notices.