+ Reply to Thread
Results 1 to 2 of 2

Automate PPT from excel macros

  1. #1
    Registered User
    Join Date
    04-30-2010
    Location
    plano,texas
    MS-Off Ver
    Excel 2003
    Posts
    2

    Automate PPT from excel macros

    I am currently working on a requirement where the excel sheet shoud automate powerpoint..
    This is my excel sheet

    For eg
    Jan Feb Mar
    East 10 30 40
    West 13 14 45
    South 34 35 33

    Each row in the excel should generate a seperate slide.
    So as per the data we r supposed to have a seperate slide for 3 zones with the months showing in a bar chart..

    I was able to code in such a way it works for a single slide and get updated automatically when the months grows in the bar chart.

    But i am not able to get for more than one slide.
    The macro should work to run dynamically ..It shud read the data from excel and update the datasheet in the powerpoint.

    The rows are going to be constant.The column grows as the months grows..

    Please can you give me a clue to continue..
    I am really struck with this

    I really thank you for your time.



    My code is pastes below written in MS xl 2003
    Sub Chart2PPT()
    Dim objPPT As Object
    Dim objPrs As Object
    Dim objGraph As Object
    Dim objDataSheet As Object
    Dim rngData As Range
    Dim intRow As Integer
    Dim intCol As Integer

    ' excel chart data
    Set rngData = Range("A1:J2")
    ' open powerpoint
    Set objPPT = CreateObject("Powerpoint.application")
    objPPT.Visible = True
    ' existing powerpoint pres
    objPPT.Presentations.Open "C:\PPt\Call_volume.ppt"
    ' chart on slide 2
    Set objPrs = objPPT.Presentations(1).slides(2)
    ' pointer to graph
    Set objGraph = objPrs.Shapes(2).OLEFormat.Object.Application
    ' pointer to graphs data sheet
    Set objDataSheet = objGraph.Datasheet
    ' transfer data
    For intRow = 1 To rngData.Rows.Count
    For intCol = 1 To rngData.Columns.Count
    objDataSheet.Cells(intRow, intCol) = rngData.Cells(intRow, intCol)
    Next
    Next
    ' update to keep changes
    objGraph.Update
    objGraph.Quit
    objPPT.Presentations(1).Save


    ' tidy up objects
    Set rngData = Nothing
    Set objGraph = Nothing
    Set objDataSheet = Nothing
    Set objPrs = Nothing
    Set objPPT = Nothing
    End Sub

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Automate PPT from excel macros

    Welcome to the forum, nitspari.

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1