Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to create sample Visual Basic for Applications code that uses Automation to create a PowerPoint 2000 presentation in Access 2000


View products that this article applies to.

This article was previously published under Q209960
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access database (.mdb).

↑ Back to the top


Summary

This article describes how to create sample Microsoft Visual Basic for Applications code that uses Automation to create a Microsoft PowerPoint 2000 presentation in Microsoft Access 2000.

↑ Back to the top


More information

  1. Start Access 2000. Open any database.
  2. Create the following new form not based on any table or query in Design view, with the control indicated:
    Form: PowerPointDemo
    Caption: PowerPoint Demo

    Command Button: cmdPowerPoint
    Name: cmdPowerPoint
    Caption: PowerPoint Example
    Width: 2"
  3. On the View menu, click Code.
  4. On the Tools menu, click References.
  5. In the Available References box, click Microsoft PowerPoint 9.0 Object Library and Microsoft Office 9.0 Object Library.
  6. Click OK to close the References dialog box.
  7. Type the following line in the Declarations section of the class module of the PowerPointDemo form:
    Dim ppObj As Object, ppPres As Object
  8. Type the following procedure:
    Private Sub cmdPowerPoint_Click()
      Dim xloop As Integer
      On Error Resume Next
      Set ppObj = GetObject(, "PowerPoint.application")
      If Err.Number Then
         Set ppObj = CreateObject("PowerPoint.Application")
         Err.Clear
      End If
      On Error GoTo err_cmdOLEPowerPoint
      Set ppPres = ppObj.Presentations.Add
    
      With ppPres
         For xloop = 1 To 5
            .Slides.Add xloop, ppLayoutTitle
            .SlideMaster.Background.Fill.PresetTextured _
               msoTextureOak
            .Slides(xloop).Shapes(1).TextFrame.TextRange.Text = _
               "Hi!  Page " & xloop
            .Slides(xloop).SlideShowTransition.EntryEffect = ppEffectFade
    
            Select Case xloop
               Case 1
                  With .Slides(xloop).Shapes(2).TextFrame.TextRange
                     .Text = "This is an Example of Automation."
                     .Characters.Font.Color.RGB = RGB(255, 255, 255)
                     .Characters.Font.Shadow = True
                  End With
                  .Slides(xloop).Shapes(1).TextFrame.TextRange. _
                     Characters.Font.Size = 50
    
               Case 2
                  With .Slides(xloop).Shapes(2).TextFrame.TextRange
                     .Text = "The programs interact seamlessly..."
                     .Characters.Font.Color.RGB = RGB(255, 0, 255)
                     .Characters.Font.Size = 48
                     .Characters.Font.Shadow = True
                  End With
                  .Slides(xloop).Shapes(1).TextFrame.TextRange. _
                     Characters.Font.Size = 90
    
               Case 3
                  With .Slides(xloop).Shapes(2).TextFrame.TextRange
                     .Text = "Demonstrating the power..."
                     .Characters.Font.Color.RGB = RGB(255, 0, 0)
                     .Characters.Font.Size = 42
                     .Characters.Font.Shadow = True
                  End With
                  .Slides(xloop).Shapes(1).TextFrame.TextRange. _
                     Characters.Font.Size = 50
    
               Case 4
                  With .Slides(xloop).Shapes(2).TextFrame.TextRange
                     .Text = "Of interoperable applications..."
                     .Characters.Font.Color.RGB = RGB(0, 0, 255)
                     .Characters.Font.Size = 34
                     .Characters.Font.Shadow = True
                  End With
                  .Slides(xloop).Shapes(1).TextFrame.TextRange. _
                     Characters.Font.Size = 100
    
               Case 5
                  With .Slides(xloop).Shapes(2).TextFrame.TextRange
                     .Text = "Created on the Fly!!!!"
                     .Characters.Font.Color.RGB = RGB(0, 255, 0)
                     .Characters.Font.Size = 72
                     .Characters.Font.Shadow = True
                  End With
                  .Slides(xloop).Shapes(1).TextFrame.TextRange. _
                     Characters.Font.Size = 60
    
            End Select
         Next
      End With
      ppPres.SlideShowSettings.Run
      Exit Sub
      err_cmdOLEPowerPoint:
      MsgBox Err.Number & " " & Err.Description
    End Sub
    					
  9. Save the PowerPointDemo form and open it in Form view.
  10. Click PowerPoint Example.

    Notice that the PowerPoint 2000 slide show is created and then appears on your screen.

↑ Back to the top


References

For additional information about using Automation with Microsoft PowerPoint, click the article number below to view the article in the Microsoft Knowledge Base:
210075� ACC2000: How to Display Microsoft PowerPoint Slides on a Form

↑ Back to the top


Keywords: KB209960, kbinterop, kbhowto

↑ Back to the top

Article Info
Article ID : 209960
Revision : 4
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 413