+ Reply to Thread
Results 1 to 1 of 1

Thread: Copy Range from Excel to Powerpoint Slide

  1. #1
    Registered User
    Join Date
    01-22-2009
    Location
    usa
    MS-Off Ver
    Excel 2003
    Posts
    30

    Copy Range from Excel to Powerpoint Slide

    I have Chart and a range, I want to copy from excel to powerpoint slide. I could copy/paste the Chart. But I cannot copy the Range to the slide as a text box.

    I want to put text box right at the bottom of the Chart, so that it looks like a Chart detail.

    Here is the code, I found from Peltiertech.com.
    Option Explicit
    
    Sub ChartsAndTitlesToPresentation()
    ' Set a VBE reference to Microsoft PowerPoint Object Library
    
    Dim PPApp As PowerPoint.Application
    Dim PPPres As PowerPoint.Presentation
    Dim PPSlide As PowerPoint.Slide
    Dim PresentationFileName As Variant
    Dim SlideCount As Long
    Dim iCht As Integer
    Dim sTitle As String
    
    ' Reference existing instance of PowerPoint
    Set PPApp = GetObject(, "Powerpoint.Application")
    ' Reference active presentation
    Set PPPres = PPApp.ActivePresentation
    PPApp.ActiveWindow.ViewType = ppViewSlide
    
    For iCht = 1 To ActiveSheet.ChartObjects.Count
        With ActiveSheet.ChartObjects(iCht).Chart
            
            ' get chart title
            If .HasTitle Then
                sTitle = .ChartTitle.Text
            Else
                sTitle = ""
            End If
            
            ' remove title (or it will be redundant)
            '.HasTitle = False
            
            ' copy chart as a picture
            .CopyPicture _
                Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
            
            ' restore title
            If Len(sTitle) > 0 Then
                .HasTitle = True
                .ChartTitle.Text = sTitle
            End If
        End With
        
        ' Add a new slide and paste in the chart
        SlideCount = PPPres.Slides.Count
        Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutTitleOnly)
        PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
        With PPSlide
        
            ' paste and select the chart picture
            .Shapes.Paste.Select
            ' align the chart
            PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
            PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
            .Shapes.Placeholders(1).TextFrame.TextRange.Text = sTitle
            
        End With
    
    Next
    
    ' Clean up
    Set PPSlide = Nothing
    Set PPPres = Nothing
    Set PPApp = Nothing
    
    End Sub
    This code can copy the Chart title and put it as a Powerpoint slide title. However, I want to use a range, to show us in the bottom center of the chart.

    I am attaching the sample sheet here. Thanks.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0