Share this Page URL

Chapter 17. Using Visual Basic to Manage... > Using Visual Basic to Work with Data... - Pg. 603

Using Visual Basic to Manage Data 603 Here's the code we've added to the button's Click event procedure so far. After we describe how this code works, we'll modify the code to add data to the first slide and add a second slide as well. Dim objPPA As PowerPoint.Application Dim objPP As PowerPoint.Presentation Dim objSlide As PowerPoint.Slide Set objPPA = New PowerPoint.Application objPPA.Visible = True Set objPP = objPPA.Presentations.Add Set objSlide = objPP.Slides.Add(1, ppLayoutText) objSlide.FollowMasterBackground = msoFalse With objSlide.Background .Fill.Visible = msoTrue .Fill.ForeColor.rgb = rgb(0, 255, 255) End With With objSlide.Shapes.Title.TextFrame.TextRange .Text = Me.txtHeadline.Value .Font.Color.RGB = RGB(0, 0, 255) .Font.Bold = True End With As with the other event procedures we've written that work with Office applications, this pro- cedure begins by declaring object variables and then assigns to the variables references to objects in the application's object model. For PowerPoint, the objects are the Application object ( objPPA ), a Presentation object ( objPP ), and a Slide object ( objSlide ). The code assigns a reference to a new instance of PowerPoint to the variable objPPA and then sets the Applica- tion object's Visible property to True.