Results 1 to 1 of 1

two excel charts per powerpoint slide

Threaded View

stubyh two excel charts per... 12-09-2013, 11:09 AM
  1. #1
    Registered User
    Join Date
    11-15-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    16

    two excel charts per powerpoint slide

    could someone point me to threads that will allow me to paste two charts from a excel sheet to a single powerpoint slide.

    I have a sheet called 'All Graphs' it has 8 charts, I would like 2 charts per slide (might need changing to say 2 then 1 then 3 but thats later), I have found out how to do a single chart per slide but need to do two to cut down on the reports side.

    thanks

    I'm using this as my base code

    Sub CreatePowerPoint_or()
    
     'Add a reference to the Microsoft PowerPoint Library by:
        '1. Go to Tools in the VBA menu
        '2. Click on Reference
        '3. Scroll down to Microsoft PowerPoint X.0 Object Library, check the box, and press Okay
     
        'First we declare the variables we will be using
            Dim newPowerPoint As PowerPoint.Application
            Dim activeSlide As PowerPoint.Slide
            Dim cht As Excel.ChartObject
         
         'Look for existing instance
            On Error Resume Next
            Set newPowerPoint = GetObject(, "PowerPoint.Application")
            On Error GoTo 0
         
        'Let's create a new PowerPoint
            If newPowerPoint Is Nothing Then
                Set newPowerPoint = New PowerPoint.Application
            End If
        'Make a presentation in PowerPoint
            If newPowerPoint.Presentations.Count = 0 Then
                newPowerPoint.Presentations.Add
            End If
         
        'Show the PowerPoint
            newPowerPoint.Visible = True
        
        'Loop through each chart in the Excel worksheet and paste them into the PowerPoint
            For Each cht In ActiveSheet.ChartObjects
            
            'Add a new slide where we will paste the chart
                newPowerPoint.ActivePresentation.Slides.Add newPowerPoint.ActivePresentation.Slides.Count + 1, ppLayoutText
                newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.Count
                Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)
                    
            'Copy the chart and paste it into the PowerPoint as a Metafile Picture
                cht.Select
                ActiveChart.ChartArea.Copy
                activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select
        
            'Set the title of the slide the same as the title of the chart
                activeSlide.Shapes(1).TextFrame.TextRange.Text = cht.Chart.ChartTitle.Text
                
            'Adjust the positioning of the Chart on Powerpoint Slide
                newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 15
                newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 125
            
                activeSlide.Shapes(2).Width = 200
                activeSlide.Shapes(2).Left = 505
                
            'If the chart is the "US" consumption chart, then enter the appropriate comments
                If InStr(activeSlide.Shapes(1).TextFrame.TextRange.Text, "US") Then
                    activeSlide.Shapes(2).TextFrame.TextRange.Text = Range("J7").Value & vbNewLine
                    activeSlide.Shapes(2).TextFrame.TextRange.InsertAfter (Range("J8").Value & vbNewLine)
            'Else if the chart is the "Renewable" consumption chart, then enter the appropriate comments
                ElseIf InStr(activeSlide.Shapes(1).TextFrame.TextRange.Text, "Renewable") Then
                    activeSlide.Shapes(2).TextFrame.TextRange.Text = Range("J27").Value & vbNewLine
                    activeSlide.Shapes(2).TextFrame.TextRange.InsertAfter (Range("J28").Value & vbNewLine)
                    activeSlide.Shapes(2).TextFrame.TextRange.InsertAfter (Range("J29").Value & vbNewLine)
                End If
                
            'Now let's change the font size of the callouts box
                activeSlide.Shapes(2).TextFrame.TextRange.Font.Size = 16
    
            Next
         
        AppActivate ("Microsoft PowerPoint")
        Set activeSlide = Nothing
        Set newPowerPoint = Nothing
         
    End Sub
    Last edited by stubyh; 12-09-2013 at 11:12 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy and paste some charts from excel into specific slide on a powerpoint template
    By ones4rus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2013, 03:00 AM
  2. [SOLVED] Copy Named charts in Excel to specific slide in Powerpoint
    By allstarrunner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2012, 09:10 AM
  3. Replies: 0
    Last Post: 12-02-2011, 12:06 PM
  4. selecting group of charts to copy to a powerpoint slide
    By amid in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-10-2009, 03:31 AM
  5. VBA: Excel sheet to Powerpoint slide
    By Herve in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-08-2005, 12:10 PM

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