Microsoft KB Archive/209960

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

Article ID: 209960

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition
 * Microsoft PowerPoint 2000 Standard Edition

-



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



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
 Start Access 2000. Open any database. 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"

 On the View menu, click Code. On the Tools menu, click References. In the Available References box, click Microsoft PowerPoint 9.0 Object Library and Microsoft Office 9.0 Object Library. Click OK to close the References dialog box.</li> Type the following line in the Declarations section of the class module of the PowerPointDemo form:

Dim ppObj As Object, ppPres As Object

</li>  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 </li> Save the PowerPointDemo form and open it in Form view.</li> Click PowerPoint Example.

Notice that the PowerPoint 2000 slide show is created and then appears on your screen.</li></ol>

Additional query words: ACC2000

<div class="references_section">