Microsoft KB Archive/262178

= PPT2000: How to Start PowerPoint 2000 by Using Windows Scripting Host =

Article ID: 262178

Article Last Modified on 7/23/2007

-

APPLIES TO


 * Microsoft PowerPoint 2000 Standard Edition

-



This article was previously published under Q262178



SUMMARY
The following Windows Scripting Host code sample demonstrates how to start PowerPoint 2000 and create a new presentation, all from a script file that you run from the desktop.



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. 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:

Sample Code
Using a text editor, create a VB Script file called RunPPT.vbs that contains the following code: ' This sample displays Windows Scripting Host properties in PowerPoint.

L_Message_Text = &quot;This script will create a PowerPoint Presentation.&quot; L_Welcome_MsgBox_Title_Text = &quot;Windows Scripting Host Sample&quot; Call Welcome

' ************************************************************************ ' * ' * PowerPoint Sample ' * Dim objPPT Dim objPres Dim objSlide

' Create an instance of PowerPoint, and then make it visible. ' Set objPPT = WScript.CreateObject(&quot;PowerPoint.Application&quot;)

objPPT.Visible = TRUE

' Create a new slide, and then assign a template to it. ' Set objPres = objPPT.Presentations.Add objPres.ApplyTemplate &quot;D:\microsoft office\templates\presentation designs\Blue Diagonal.pot&quot;

' Create a new slide and assign it to objSlide. This ' demonstrates one method of manipulating slides. The first value, ' 1, is the slide position in the presentation. In this case it is the ' first slide. The second parameter is the long value for the PpSlideLayout ' type &quot;ppLayoutTitle&quot;. ' set objSlide = objPres.Slides.Add(1, 1)

' Shape one on a title slide is always the title placeholder; Shape 2 is ' always the subtitle placeholder. ' objSlide.Shapes(1).TextFrame.TextRange.Text = &quot;Windows Scripting &quot; & _ &quot;Host Example&quot;

objSlide.Shapes(2).TextFrame.TextRange.Text = &quot;This slide was created&quot; & _ &quot; by script running from the Windows Scripting Host.&quot;

' In this example, we add a new slide after slide 1, and give it the ' layout type of ppLayoutText for a bulleted list slide. ' objPres.Slides.Add 2, 2

' Same as before, the first shape on the slide is the title placeholder. ' For a text slide, the next object is the text placeholder. The vbNewLine ' constant places a carriage return and linefeed command after each text ' phrase. ' objPres.Slides(2).Shapes(1).TextFrame.TextRange.Text = &quot;New Slide Title&quot; objPres.Slides(2).Shapes(2).TextFrame.TextRange.Text = &quot;Line one&quot; & _ vbNewLine & &quot;Line two&quot; & vbNewLine & &quot;Line three&quot;

' ************************************************************************ ' * ' * Welcome ' * Sub Welcome Dim intDoIt

intDoIt = MsgBox(L_Message_Text, _                      vbOKCancel + vbInformation,    _                      L_Welcome_MsgBox_Title_Text ) If intDoIt = vbCancel Then WScript.Quit End If End Sub

