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

Article translations Article translations
Article ID: 209960 - 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).

Expand all | Collapse all

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.

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.

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

Properties

Article ID: 209960 - Last Review: October 11, 2006 - Revision: 2.2
APPLIES TO
  • Microsoft Access 2000 Standard Edition
  • Microsoft PowerPoint 2000 Standard Edition
Keywords: 
kbhowto kbinterop KB209960

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com