locked
Export Excel charts to PowerPoint RRS feed

  • Question

  • Hi all,

    I have a requirement to take some charts from Excel Workbooks (in SharePoint) and export them to PowerPoint.  I am doing this from a WPF application.  Does anyone have any sample code or at least be able to point me in the right direction?  I would greatly appreciate it.

    Thanks,

    Rhonda

     

    Friday, July 9, 2010 11:03 PM

Answers

  • Rhonda,

    # PowerPoint Document

    Would it be possible to create a template that You can use in the solution. In that way You can create a template which You then populate with charts etc. So when Your solution open the template file it actually create a copy of it to be used. Load and saving a document should not be so hard to resolve (although I have limited knowledge with WPF).

    # Iteration

    The following snippet VB code shows how You can do it:

     Dim xlApp As New Excel.Application
    
        Dim wbSource As Excel.Workbook = xlApp.Workbooks.Open("c:\Test\Source.xlsx")
        
        For Each wsSheet As Excel.Worksheet In wbSource.Worksheets
          For Each wcChart As Excel.ChartObject In CType(wsSheet.ChartObjects, _<br/>
                                  Excel.ChartObjects)
            MessageBox.Show(wcChart.Name.ToString)
          Next
        Next
    
        With xlApp
          .Visible = True
          .UserControl = True
        End With
    
        wbSource = Nothing
        xlApp = Nothing
    


    Kind regards, Dennis (http://xldennis.wordpress.com/)
    • Marked as answer by Skydolphin Tuesday, July 13, 2010 5:42 PM
    Tuesday, July 13, 2010 12:12 AM

All replies

  • Hi Rhonda

    If you don't get any responses here, you might try a PowerPoint forum. They (by their own wish) don't have a separate "Developer" forum, so it's not so easy for you to find

    http://social.answers.microsoft.com/Forums/en-US/group/Office

    You should always mention the version of Office you're targeting, as this will definitely affect the possibilities open to you. If this is Office 2007 or 2010, I very much recommend you look into working directly with the closed files: the Office OpenXML file format. You'll find more on this at OpenXMLDeveloper.org, plus there's an OpenXML SDK for Visual Studio .NET and a forum that supports it. This would let you extract the chart from the Excel file, as an XML document and drop it into the PowerPoint file. You'd basically need to learn how to put it on a slide, and set up the necessary "References" in the OpenXML file package. This approach would be preferable to having to "interop" two Office applications in a server environment...


    Cindy Meister, VSTO/Word MVP
    Saturday, July 10, 2010 11:14 AM
  • See if the following can get You started:

    Inserting Excel Charts into PowerPoint 2007
    http://msdn.microsoft.com/en-us/library/bb676881(v=office.12).aspx


    Kind regards, Dennis (http://xldennis.wordpress.com/)
    Saturday, July 10, 2010 11:42 AM
  • Try this:

    http://peltiertech.com/Excel/XL_PPT.html

    This is a great source for VBA in PowerPoint:

    http://www.pptfaq.com/index.html

     

    I suspect you will find something in there that is useful!!

    Good luck!!

    Saturday, July 10, 2010 9:00 PM
  • http://www.pptfaq.com/index.html

    http://peltiertech.com/Excel/XL_PPT.html

     

    Good luck!!

    Saturday, July 10, 2010 9:03 PM
  • I'm using office 2010. 

    Thanks,

    Rhonda

     

    Monday, July 12, 2010 9:40 PM
  • Dennis,  That mostly works.  The two things I need to figure out is how to create the document and then save it.  Currently it will only save if I already have a document with that name created.  The other option I was thinking was to just leave PowerPoint open and make the user save it to whereever they want it. 

    I also need to iterate through the workbook and grab all the charts from all the sheets and add them. But other than that it works. 

     

    Rhonda

    Monday, July 12, 2010 11:02 PM
  • Rhonda,

    # PowerPoint Document

    Would it be possible to create a template that You can use in the solution. In that way You can create a template which You then populate with charts etc. So when Your solution open the template file it actually create a copy of it to be used. Load and saving a document should not be so hard to resolve (although I have limited knowledge with WPF).

    # Iteration

    The following snippet VB code shows how You can do it:

     Dim xlApp As New Excel.Application
    
        Dim wbSource As Excel.Workbook = xlApp.Workbooks.Open("c:\Test\Source.xlsx")
        
        For Each wsSheet As Excel.Worksheet In wbSource.Worksheets
          For Each wcChart As Excel.ChartObject In CType(wsSheet.ChartObjects, _<br/>
                                  Excel.ChartObjects)
            MessageBox.Show(wcChart.Name.ToString)
          Next
        Next
    
        With xlApp
          .Visible = True
          .UserControl = True
        End With
    
        wbSource = Nothing
        xlApp = Nothing
    


    Kind regards, Dennis (http://xldennis.wordpress.com/)
    • Marked as answer by Skydolphin Tuesday, July 13, 2010 5:42 PM
    Tuesday, July 13, 2010 12:12 AM
  • Dennis,

    What I ended up doing is creating a template in our sharepoint server that gets used to create the presentation.  I don't close powerpoint so the user has the opportunity to save as to save it to their machine. Seems to work pretty well.

    Thanks for the help and suggestions.

    Rhonda

     

    Tuesday, July 13, 2010 5:42 PM
  • You're welcome!

    Kind regards, Dennis (http://xldennis.wordpress.com/)
    Tuesday, July 13, 2010 10:36 PM