Private Sub Command1_Click()
    Dim xApp As New PowerPoint.Application
    Dim xDoc As New PowerPoint.Presentation
    
    xApp.Visible = msoCTrue
    Set xDoc = xApp.Presentations.Open("C:\WINNT\Profiles\Administrator\Personal\VSS使用简介.ppt")
    xDoc.NewWindow
    xDoc.Save
    xDoc.Close
    
    Set xDoc = Nothing
    xApp.Quit
    Set xApp = Nothing
End Sub

解决方案 »

  1.   

    Application 对象
                            
     
    代表整个 Microsoft Outlook 应用程序。这是分层结构中可使用 CreateObject 方法或内部 Visual Basic GetObject 函数返回的唯一对象。Outlook Application 对象有以下几个用途: 作为根对象,使用它可访问 Outlook 分层结构中的其他对象。
    允许直接访问使用 CreateItem 创建的新项目,而不用遍历对象分层结构。
    允许访问活动接口对象(浏览器和检查器)。 
    使用 Application 对象使用“Automation”从其他应用程序控制 Microsoft Outlook 时,用户使用 CreateObject 方法创建 Outlook Application 对象。下面的 Visual Basic for Applications 示例启动 Microsoft Outlook(如果还没有运行)并打开默认的“收件箱”文件夹。Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNameSpace("MAPI")
    Set myFolder= _
        myNameSpace.GetDefaultFolder(olFolderInbox)
    myFolder.Display
    下面的 Visual Basic for Applications 使用 Application 对象创建并打开新联系人。Set myOlApp = CreateObject("Outlook.Application")
    Set myItem = myOlApp.CreateItem(olContactItem)
    myItem.Display
      

  2.   

    Use CreateObject to Print Slides From A Presentation 
       
    --------------------------------------------------------------------------------Using the Shell call to the print a PowerPoint Presentation using the /P parameter is an alternative. However you might want to print specific slides (not tackled in this example) which cannot be achieved using the Shell call. This example uses the CreateObject call to create an instance of PowerPoint, Open the file and then Print it. This can be used from any VB/VBA app to print a presentation. ' --------------------------------------------------------------------------------
    ' Copyright ©1999-2000, Shyam Pillai, All Rights Reserved.
    ' --------------------------------------------------------------------------------
    ' You are free to use this code within your own applications, add-ins,
    ' documents etc but you are expressly forbidden from selling or 
    ' otherwise distributing this source code without prior consent.
    ' This includes both posting free demo projects made from this
    ' code as well as reproducing the code in text or html format.
    ' --------------------------------------------------------------------------------Sub PrintPPT()
        Dim AppPPT As Object
        Set AppPPT = CreateObject("PowerPoint.Application")
        AppPPT.Visible = True
        ' If you want to hide the PowerPoint Window, set the visible property
        ' to FALSE  and WithWindow argument of Open method to FALSE too.
        With AppPPT.Presentations.Open("c:\sample.ppt")
            DoEvents
        ' Use .PrintOptions property to specify any additional settings 
        ' Set background printing off else, PowerPoint will terminate
        ' before printing is completed.
            .PrintOptions.PrintInBackground = False
            .PrintOut  
            .PrintOptions.PrintInBackground = True
        End With
        AppPPT.Quit
        Set AppPPT = Nothing
    End Sub-------------------------------------------------------------------------------- 
     
    Global Find And Replace routine in PowerPoint
     
     
    --------------------------------------------------------------------------------Let's take a look at how to make use of the Replace method of the TextRange object in PowerPoint to create a global find and replace routine which replaces the text across all open presentations. The PowerPoint 2000 VBA help file example is incorrect.Top
    --------------------------------------------------------------------------------' --------------------------------------------------------------------------------
    ' Copyright ©1999-2000, Shyam Pillai, All Rights Reserved.
    ' --------------------------------------------------------------------------------
    ' You are free to use this code within your own applications, add-ins,
    ' documents etc but you are expressly forbidden from selling or 
    ' otherwise distributing this source code without prior consent.
    ' This includes both posting free demo projects made from this
    ' code as well as reproducing the code in text or html format.
    ' --------------------------------------------------------------------------------Sub GlobalFindAndReplace()
       Dim oPres As Presentation
       Dim oSld As Slide
       Dim oShp As Shape
       Dim oTxtRng As TextRange
       Dim oTmpRng As TextRange
       Dim FindString As String, ReplaceString As String
        
       FindString = "Like"
       ReplaceString = "Not Like"
        
       For Each oPres In Application.Presentations
       For Each oSld In oPres.Slides
       For Each oShp In oSld.Shapes
          If oShp.HasTextFrame Then
          If oShp.TextFrame.HasText Then
        
            Set oTxtRng = oShp.TextFrame.TextRange
            Set oTmpRng = oTxtRng.Replace(FindWhat:=FindString, _
            Replacewhat:=ReplaceString, WholeWords:=True)
            Do While Not oTmpRng Is Nothing
            Set oTmpRng = oTxtRng.Replace(FindWhat:=FindString, _
                                          Replacewhat:=ReplaceString, _
                                          After:=oTmpRng.Start + oTmpRng.Length, _
                                          WholeWords:=True)
            Loop
          End If
          End If
       Next oShp
       Next oSld
       Next oPres
    End Sub