Share via

How to create a powerpoint presentation from SQl Server without using Reporting Services? We want to develop a solution which creates powerpoint presentation from varous sql result sets

Anonymous
2012-05-14T09:39:48+00:00

How to create a powerpoint presentation from SQl Server without using Reporting Services? We want to develop a solution which creates powerpoint presentation from varous sql result sets

Microsoft 365 and Office | PowerPoint | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Steve Rindsberg 99,161 Reputation points MVP Volunteer Moderator
    2012-05-14T16:10:33+00:00

    That's a topic for a book, if you can persuade someone to write it.  Or to take up with a developer.

    It's way too large a topic to tackle in a forum like this.

    If you've started the project and need help with the PowerPoint coding part of it, we're certainly willing to help, but you'll need to break it down into smaller questions as you run into problems.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2017-02-02T13:30:34+00:00

    I am looking to do this also, however trying to avoid reporting services seems quite tricky.  In the mean time, and apologies as I know this is an old thread but I have this which is VBA code run from a PowerPoint to populate a table with the results from a SQL query.

    New Sub Routine:

    Dim conn

    Dim rs

    Dim cs As String

    Dim query As String

    Dim row As Integer

    Public Details

    Dim icol As Integer, irow As Integer, minW As Single

    Sub MYPERSONAL_SQLServer_Connection()

    '** Check connection and only run if connection is closed

        If IsObject(cn) = False Then

        Set cn = CreateObject("ADODB.Connection")

        Set rs = CreateObject("ADODB.Recordset")

        cn.ConnectionString = "Provider=SQLOLEDB.1;Data Source=mymachine\mySQLEXPRESS; Initial Catalog=mydatabase; user id=myuser; password=mypword"

    '** Open Con

        cn.Open

    '** SQL Script goes here

     Qry = "Select col1, "

     Qry = Qry & "col2, "

     Qry = Qry & "col3, "

     Qry = Qry & "From mysqltable "

    '** Open the query and run throught the records

        Set RecSet = cn.Execute(Qry, adAsyncConnect)

    '** Start from the beginning & count the records

        RecSet.MoveFirst

            col = RecSet.Fields.Count

            i = 0

                Do Until RecSet.EOF = True

                    i = i + 1

                    RecSet.MoveNext

                Loop

            row = i

        RecSet.MoveFirst

    '** Remove and cleanup previous Powerpoint table

        With ActivePresentation.Slides(1)

            For Each Shp In ActivePresentation.Slides(1).Shapes

                Shp.Delete

            Next Shp

        End With

    '** Build the Powerpoint table

        With ActivePresentation.Slides(1).Shapes.AddTable(row + 1, col)

            ReDim textShapes(0 To 2)

                i = 0

                    For Each Shape In ActivePresentation.Slides(1).Shapes

                        If Shape.HasTable Then

                        Shape.Name = "prbTable"

                    End If

            Next Shape

        End With

    r = 2

    c = 1

    '** Build the rows per field item        #Details = Details & Field & "|"

    Set oPPTShape = ActivePresentation.Slides(1).Shapes("prbTable")

     With oPPTShape.Table

            .Cell(1, 1).Shape.TextFrame.TextRange.Text = "Col1"

            .Cell(1, 1).Shape.TextFrame.TextRange.Font.Size = 8

            .Cell(1, 1).Shape.TextFrame.TextRange.Font.Bold = True

            .Cell(1, 1).Shape.TextFrame.HorizontalAnchor = msoAnchorCenter

            .Cell(1, 2).Shape.TextFrame.TextRange.Text = "Col2"

            .Cell(1, 2).Shape.TextFrame.TextRange.Font.Size = 8

            .Cell(1, 2).Shape.TextFrame.TextRange.Font.Bold = True

            .Cell(1, 2).Shape.TextFrame.HorizontalAnchor = msoAnchorCenter

            .Cell(1, 3).Shape.TextFrame.TextRange.Text = "Col3" 

            .Cell(1, 3).Shape.TextFrame.TextRange.Font.Size = 8

            .Cell(1, 3).Shape.TextFrame.TextRange.Font.Bold = True

            .Cell(1, 3).Shape.TextFrame.HorizontalAnchor = msoAnchorCenter

         End With

        While Not RecSet.EOF

            For Each Field In RecSet.Fields

                If Field <> "" Then oPPTShape.Table.Cell(r, c).Shape.TextFrame.TextRange.Text = Field

                oPPTShape.Table.Cell(r, c).Shape.TextFrame.TextRange.Font.Size = 8

                c = c + 1

            Next

    c = 1

    r = r + 1

                RecSet.MoveNext

        Wend

    End If

    Set cn = Nothing

    'MsgBox ActivePresentation.PageSetup.SlideWidth

    'MsgBox ActivePresentation.PageSetup.SlideHeight

    With oPPTShape

        .Height = 150

        .Width = 750

        .Left = 19

        .Top = 89

        .Table.Columns(2).Width = 57

    End With

    End Sub

    I can't remember where I got the basics for this so sorry I can't post the thanks but I adjusted some for my own purposes to retrieve data.  This is one set to one slide.  I am in the process of trying to have an active Module to execute new slide creation with executed query results.

    Anyway, only 5 years late, but if anyone is interested.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Steve Rindsberg 99,161 Reputation points MVP Volunteer Moderator
    2017-02-02T17:00:40+00:00

    A good answer is a prize; no need for apologies.  The original question may have been five years ago but that's not relevant to someone with the same problem today or tomorrow.

    Thanks!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-01-17T19:33:25+00:00

    You may want to consider SoftArtisans PowerPointWriter, which is a .NET API that uses a template-based approach to populating presentations with data. The template contains placeholders that will be replaced with data, images etc. Then you bind data to the template with very little code. 

    PowerPointWriter has built-in behaviors to make it easy to import many rows of data, such as repeating slides, lists, and tables. It's also designed to handle multiple data sets.  You could create a .NET application that uses a generic template to import different data sets into a presentation. There are code samples and tutorials available for getting started.

    Disclaimer: I work for SoftArtisans, makers of PowerPointWriter

    Was this answer helpful?

    0 comments No comments