Access - Add additional slides (based on initial slide and update objects from Query results

I have a template PPT file has a title slide and then a 2nd slide that has blank content with a header title and a table object with some elements that are placeholders.

I am trying to find out if it is possible to step through results of an Access query and create a new slide from the template with the necessary fields populated in the title and the corresponding cells in the table.

I have tried to find references to this online and nothing seems to specifically step through the coding needs.

thanks for any help!

aehrenwoTechnology AnalystAsked:
Who is Participating?

Since you are in Access you have to reference the PP object if you want to use its properties

                ppapp.ActivePresentation.Slides(ppapp.ActivePresentation.Slides.Count).MoveTo toPos:=ppapp.ActivePresentation.Slides.Count + 1
                ppapp.ActivePresentation.Slides(ppapp.ActivePresentation.Slides.Count).Shapes(3).TextFrame.TextRange.Text = CStr(rs.Fields("Title").Value)

Open in new window

aehrenwoTechnology AnalystAuthor Commented:
I created the following code... it opens the necessary template PowerPoint but it will not make the necessary changes. I am trying to copy the 2nd slide and then update certain shapes on that newly create pages for each item in the recordset returned.

Option Compare Database

'Show/Hide Dropdown options based on Report Selection
Private Sub ReportType_AfterUpdate()

If Me.ReportType.Value = "HCCO Presentation" Then
Me.Company_Label.Visible = True
Me.Company.Visible = True
Me.HCCOOwner_Label.Visible = True
Me.HCCOOwner.Visible = True
Me.Interaction_Label.Visible = True
Me.Interaction.Visible = True
End If

If Me.ReportType.Value <> "HCCO Presentation" Then
Me.Company_Label.Visible = False
Me.Company.Visible = False
Me.HCCOOwner_Label.Visible = False
Me.HCCOOwner.Visible = False
Me.Interaction_Label.Visible = False
Me.Interaction.Visible = False
End If

End Sub

Private Sub RunReport_Click()
If Me.ReportType.Value = "HCCO Presentation" Then
    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("RAMP_HCCOOwner_temp", dbOpenDynaset)
    ' Open up an instance of Powerpoint.
    Set ppObj = New PowerPoint.Application

    ' Setup the set of slides and populate them with data from the
    ' set of records.

     ppObj.Presentations.Open ("C:\PGHCC Tools\RAMP_ReportingDB\template\Committee_Meeting.pptx")
     On Error Resume Next
    For x = 1 To rs.RecordCount
     Set ppapp = GetObject(, "Powerpoint.Application")
     If ppapp Is Nothing Then
     Set ppapp = CreateObject("Powerpoint.Application")
     ppapp.Visible = True
     End If
                ActivePresentation.Slides(ActivePresentation.Slides.Count).MoveTo toPos:=ActivePresentation.Slides.Count + 1
                ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes(3).TextFrame.TextRange.Text = CStr(rs.Fields("Title").Value)
    Exit Sub
    MsgBox Err.Number & " " & Err.Description
End If

End Sub

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.