padlocked17
Registered User.
- Local time
- Today, 16:58
- Joined
- Aug 29, 2007
- Messages
- 276
Alright everyone. I've got some code workin quite well that is is the beginning stages of pulling data from the database and then making a Powerpoint Slide.
I've got a recordset created that is pulling from a table, but what I need to do is two-fold:
1) Create a recordset that pulls from multiple tables (Almost like a query. I haven't looked into this yet, but I need to do it)
2) Create a set number of slides that display's a pre-defined list of headers and columns and then automatically populates the rest of the table's cells if information is applicable.
To start I want three slides that display information based on calculated date criteria. There is a date entered in for each student and I want to calculate if that month is 18 months or more from a date entered for the first slide, between 15 and 17 months for the second slide, and between 12 and 14 months for the third slide.
I'm using the following code and it's well commented if someone wants to steal if for future use:
I've got a recordset created that is pulling from a table, but what I need to do is two-fold:
1) Create a recordset that pulls from multiple tables (Almost like a query. I haven't looked into this yet, but I need to do it)
2) Create a set number of slides that display's a pre-defined list of headers and columns and then automatically populates the rest of the table's cells if information is applicable.
To start I want three slides that display information based on calculated date criteria. There is a date entered in for each student and I want to calculate if that month is 18 months or more from a date entered for the first slide, between 15 and 17 months for the second slide, and between 12 and 14 months for the third slide.
I'm using the following code and it's well commented if someone wants to steal if for future use:
Code:
Sub cmdPowerPoint_Click()
Dim db As Database, rs As Recordset
Dim ppObj As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
On Error GoTo err_cmdOLEPowerPoint
' Open up a recordset on the Employees table.
Set db = CurrentDb
Set rs = db.OpenRecordset("tblStudents", dbOpenDynaset)
' Open up an instance of Powerpoint.
Set ppObj = New PowerPoint.Application
Set ppPres = ppObj.Presentations.Add
' Setup the set of slides and populate them with data from the
' set of records.
With ppPres
While Not rs.EOF
With .Slides.Add(rs.AbsolutePosition + 1, ppLayoutTitle)
.Shapes(1).TextFrame.TextRange.Text = "Hi! Page " & rs.AbsolutePosition + 1
'Specifying the transition that we will use for each slide
.SlideShowTransition.EntryEffect = ppEffectFade
' Specifying that we want to advance the slides automatically
.SlideShowTransition.AdvanceOnTime = True
' Specifying that we want the slides to advance every 3 seconds
.SlideShowTransition.AdvanceTime = 3
With .Shapes(2).TextFrame.TextRange
.Text = CStr(rs.Fields("LastName").Value)
.Characters.Font.Color.RGB = RGB(255, 0, 255)
.Characters.Font.Shadow = True
End With
.Shapes(1).TextFrame.TextRange.Characters.Font.Size = 50
End With
rs.MoveNext
Wend
End With
' These items specify that we want to used the Slide Show Timing specified above and to loop
' until the user stops the loop
With ppPres.SlideShowSettings
.RangeType = ppShowSlideRange
' Only use the following if you want specific slides to be shown
'.StartingSlide = 2
'.EndingSlide = 4
.AdvanceMode = ppSlideShowUseSlideTimings
.LoopUntilStopped = True
'.Run
End With
' Save the presentation to a file. If used comment out the .Run line above
'ppPres.SaveAs "C:\Documents and Settings\williamsn\Desktop\YourFileName.ppt", ppSaveAsPresentation
' Run the show. This command replaced with the .Run above
ppPres.SlideShowSettings.Run
Exit Sub
err_cmdOLEPowerPoint:
MsgBox Err.Number & " " & Err.Description
End Sub