The information in this article applies to:
SUMMARYThis article describes how to use the Microsoft Visual Basic for Applications Presentations.Open method. The Open method opens an existing Microsoft PowerPoint presentation. 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 professionals 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/overview/overview.asp ParametersThere are four parameters that you can use to control the behavior of the Open method:
FileName:
The FileName parameter is the path and name of the presentation you wish to open. The following Visual Basic example opens a file named test.ppt located in the C:\ root directory.ReadOnly: The ReadOnly parameter is used to open a presentation as Read-Only. The following example opens a file named test.ppt as Read-Only.Untitled:The parameter, msoTrue, tells PowerPoint to open the presentation ReadOnly. When test.ppt is open, the following text appears in the title bar: The Untitled parameter is used to create a copy of the presentation. The following example opens a copy of test.ppt.WithWindow:If you do not specify the msoTrue parameter, it is set to msoFalse (the default), and the file name only appears in the title bar: The WithWindow parameter open a presentation without making it visible. The following example opens test.ppt, does not show it, and then closes it.NOTE: When you are finished with the invisible presentation, make sure you close the presentation. Using the Return ValueThe Open method returns a reference to a presentation object. Once you have the object reference, you can use it to access methods and properties of the presentation.
NOTE: To use the return value of a method, set the method to a variable and
enclose the parameters in parentheses.
Error Trapping the Open MethodThe following sample code demonstrates how you can trap errors that may occur when using the Open method:
The On Error Resume Next statement allows the macro to continue to execute
beginning with the statement that immediately follows the statement that
generated the error. If you do not use the On Error Resume Next statement,
you will receive a run-time error if the file cannot be opened and the
macro halts. When a run-time error occurs, information about that error is
stored in the Err object.
For more information about the Err object, search the Help Index for "Err," or ask the Microsoft PowerPoint 97 Office Assistant. REFERENCESFor additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base: Q163435 VBA: Programming Resources for Visual Basic for Applications Additional query words: 97 8.00 kbmacro kbpptvba ppt8 vba vbe 8.0 kbhowto
Keywords : kbcode kbmacro kbprg kbdta kbdtacode kbpptvba |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |