Consulting

Results 1 to 11 of 11

Thread: Copy Charts from Excel to power point 2007 and save as.

  1. #1

    Copy Charts from Excel to power point 2007 and save as.

    Hi all!

    I wanted to post a new thread it id not allow me.

    This is what i need to do, I have an excel file (2007) with charts that I wan to copy to an specific power point format where the charts would be copy to an specific slide, height, width and position, then it must be saves depending on a value reference to a cell.
    This is the code I have started, but for save it shows me the error 91. I just have the beginning and the of my desire code.
    Thanks in avance for your help.

    Sub Open_PowerPoint_Presentation()
    'Opens a PowerPoint Document from Excel


    Dim objPPT As Object
    Dim PPPres As PowerPoint.Presentation
    Dim PPApp As PowerPoint.Application
    Dim Name As Variant




    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    'PPApp.Visible = True




    'Change the directory path and file name to the location
    'of your document


    objPPT.Presentations.Open "C:\Users\jose_jimenez2\Documents\test\test.ppt"
    'Set PPPres = PPApp.ActivePresentation


    Sheets("Sheet1").Select
    Range("P1").Select
    Name = Cells(1, 16)






    If Name = 1 Then


    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test1\test1.ppt" Here is where the error is showed.
    End With
    Else


    If Name = 2 Then
    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test2\test2.ppt"
    End With
    Else

    If Name = 3 Then
    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test3\test3.ppt"
    .Close
    End With
    Else
    End If
    End If
    End If
    End Sub

  2. #2

    Copy Charts from Excel to power point 2007 and save as

    Hi all!

    This is what I need help, I have an excel file (2007) with charts that I wan to copy to an specific power point format where the charts would be copy to an specific slide, height, width and position, then it must be saves depending on a value reference to a cell.
    This is the code I have started, but for save it shows me the error 91. I just have the beginning and the of my desire code.
    Thanks in avance for your help.

    Sub Open_PowerPoint_Presentation()
    'Opens a PowerPoint Document from Excel


    Dim objPPT As Object
    Dim PPPres As PowerPoint.Presentation
    Dim PPApp As PowerPoint.Application
    Dim Name As Variant




    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    'PPApp.Visible = True




    'Change the directory path and file name to the location
    'of your document


    objPPT.Presentations.Open "C:\Users\jose_jimenez2\Documents\test\test.ppt"
    'Set PPPres = PPApp.ActivePresentation


    Sheets("Sheet1").Select
    Range("P1").Select
    Name = Cells(1, 16)






    If Name = 1 Then


    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test1\test1.ppt" Here is where the error is showed.
    End With
    Else


    If Name = 2 Then
    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test2\test2.ppt"
    End With
    Else

    If Name = 3 Then
    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test3\test3.ppt"
    .Close
    End With
    Else
    End If
    End If
    End If
    End Sub

  3. #3
    I have corrected the code and I can copy and paste the char to power point with specific size and position, but I have more charts to copy to an specific slide number, how can I set up the chart number from Excel to the Slide number on the power point>

    Sub Open_PowerPoint_Presentation()
    'Opens a PowerPoint Document from Excel
    
    Dim objPPT As Object
    Dim PPPres As PowerPoint.Presentation
    Dim PPApp As PowerPoint.Application
    Dim Name As Variant
    
    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    objPPT.Presentations.Open "C:\Users\jose_jimenez2\Documents\test\test.ppt"
    Set PPApp = GetObject(, "Powerpoint.Application")
    Set PPPres = PPApp.ActivePresentation
    copy_chart "sheet1", 2 ' Name of the sheet to copy graph and slide number the graph is to be pasted in
    
    
    Sheets("Sheet1").Select
    Range("P1").Select
    Name = Cells(1, 16)
    If Name = 1 Then
    
    
    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test1\test1.ppt"
    End With
    Else
    
    
    If Name = 2 Then
    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test2\test2.ppt"
    End With
    Else
    
    If Name = 3 Then
    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test3\test3.ppt"
    
    End With
    Else
    End If
    End If
    End If
    
    ' Set PPSlide = Nothing
    'Set PPPres = Nothing
    'Set PPApp = Nothing
    End Sub

    Public Function copy_chart(sheet, slide)
    
    Dim PPAp As Object
    Dim PPPre As Object
    Dim PPSlide As Object
    
    
    Set PPAp = CreateObject("Powerpoint.Application")
    '***Set PPPres = CreateObject("Powerpoint.Presentation")***
    
    Set PPAp = GetObject(, "Powerpoint.Application")
    Set PPPre = PPAp.ActivePresentation
    PPAp.ActiveWindow.ViewType = ppViewSlide
    PPAp.ActiveWindow.View.GotoSlide (slide)
    
    Worksheets(sheet).Activate
    Sheets(sheet).ChartObjects("chart 1").Chart.ChartArea.Copy
    ActiveSheet.ChartObjects("Chart 1").Chart.CopyPicture _
    Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
    
    Set PPSlide = PPPre.Slides(PPAp.ActiveWindow.Selection.SlideRange.SlideIndex)
    With PPSlide
    'paste and select the chart picture
    .Shapes.Paste.Select
    ' align the chart
    
    With PPAp.ActiveWindow.Selection.ShapeRange
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    End With
    End With
    End Function
    Last edited by SamT; 01-24-2016 at 06:43 PM.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    My fault. I was editing a post in the other thread then.

    I now merged this thread with that one.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    I made it work, but I need now to copy text from a range in Excel to powerpoint, when code goes to this points it gets me an error 424 (Line bold)

    Can you help me please

    Sub Open_PowerPoint_Presentation()
    'Opens a PowerPoint Document from Excel
    
    Dim objPPT As Object
    Dim PPPres As PowerPoint.Presentation
    Dim PPApp As PowerPoint.Application
    Dim Name As Variant
    
    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    objPPT.Presentations.Open "C:\Users\jose_jimenez2\Documents\test\test.ppt"
    Set PPApp = GetObject(, "Powerpoint.Application")
    Set PPPres = PPApp.ActivePresentation
    copy_chart "sheet1", 2 ' Name of the sheet to copy graph and slide number the graph is to be pasted in
    
    Sheets("Sheet1").Select
    Range("P1").Select
    Name = Cells(1, 16)
    
    If Name = 1 Then
    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test1\test1.ppt"
    End With
    Else
    
    If Name = 2 Then
    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test2\test2.ppt"
    End With
    Else
    
    If Name = 3 Then
    With PPPres
    .SaveAs "C:\Users\jose_jimenez2\Documents\test\test3\test3.ppt"
    
    End With
    Else
    End If
    End If
    End If
    
    ' Set PPSlide = Nothing
    'Set PPPres = Nothing
    'Set PPApp = Nothing
    End Sub
    Public Function copy_chart(sheet, slide)
    ' Uses Early Binding to the PowerPoint Object Model
    ' 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 oPPShape As Object
    Dim oPPSlide As Object
    
    ' Reference existing instance of PowerPoint
    Set PPApp = GetObject(, "Powerpoint.Application")
    ' Reference active presentation
    Set PPPres = PPApp.ActivePresentation
    PPApp.ActiveWindow.ViewType = ppViewSlide
    
    'Copy "Chart 1" on "Sheet1" to Slide # 2
    ' Copy "Chart 1" on "Sheet1" as a picture
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 1").CopyPicture
    ' Paste chart to Slide # 2
    With PPPres.Slides(2).Shapes.Paste
    ' Align pasted chart
    '.Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    Set oPPShape = oPPSlide.Shapes(1)
    '~~> Write to the shape
    oPPShape.TextFrame.TextRange.Text = _
    TActiveWorkbook.Sheets("Sheet1").Range("C2:C5").Value
    End With
    
    'Copy "Chart 2" to from "Sheet1" to Slide #
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 2").CopyPicture
    ' Paste chart to Slide # 4
    With PPPres.Slides(4).Shapes.Paste
    ' Align pasted chart
    ' .Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    And With
    
    'Copy "Chart 3" to from "Sheet1" to Slide # 5
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 3").CopyPicture
    ' Paste chart to Slide # 4
    With PPPres.Slides(5).Shapes.Paste
    ' Align pasted chart
    '.Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    End With
    
    'Copy "Chart 4" to from "Sheet1" to Slide # 6
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 4").CopyPicture
    ' Paste chart to Slide # 4
    With PPPres.Slides(6).Shapes.Paste
    ' Align pasted chart
    '.Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    End With
    
    'Copy "Chart 5" to from "Sheet1" to Slide # 7
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 5").CopyPicture
    ' Paste chart to Slide # 4
    With PPPres.Slides(7).Shapes.Paste
    ' Align pasted chart
    '.Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    End With
    
    'Copy "Chart 6" to from "Sheet1" to Slide # 8
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 6").CopyPicture
    ' Paste chart to Slide # 4
    With PPPres.Slides(8).Shapes.Paste
    ' Align pasted chart
    '.Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    End With
    
    'Copy "Chart 7" to from "Sheet1" to Slide # 9
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 7").CopyPicture
    ' Paste chart to Slide # 4
    With PPPres.Slides(9).Shapes.Paste
    ' Align pasted chart
    '.Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    End With
    
    'Copy "Chart 8" to from "Sheet1" to Slide # 10
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 8").CopyPicture
    ' Paste chart to Slide # 4
    With PPPres.Slides(10).Shapes.Paste
    ' Align pasted chart
    '.Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    End With
    
    'Copy "Chart 9" to from "Sheet1" to Slide # 12
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 9").CopyPicture
    ' Paste chart to Slide # 4
    With PPPres.Slides(12).Shapes.Paste
    ' Align pasted chart
    '.Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    End With
    
    'Copy "Chart 10" to from "Sheet1" to Slide # 13
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 10").CopyPicture
    ' Paste chart to Slide # 4
    With PPPres.Slides(13).Shapes.Paste
    ' Align pasted chart
    '.Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    End With
    
    'Copy "Chart 11" to from "Sheet1" to Slide # 14
    ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 11").CopyPicture
    ' Paste chart to Slide # 4
    With PPPres.Slides(14).Shapes.Paste
    ' Align pasted chart
    '.Align msoAlignCenters, True
    '.Align msoAlignMiddles, True
    .LockAspectRatio = msoFalse
    .Width = 534.9034263959
    .Height = 165.5603448276
    .Left = 0
    .Top = 34.2786890756
    End With
    
    ' Clean up
    Set PPSlide = Nothing
    Set PPPres = Nothing
    Set PPApp = Nothing
    End Function
    Last edited by SamT; 01-25-2016 at 03:47 PM.

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I noticed that you have a typo, "And With" vice "End With."

    I refactored the code for sped and readability. There is a syntax error, commented in the code below, that I can't fix.
    Option Explicit
    
    
    Public Function copy_chart(sheet, slide)
         ' Uses Early Binding to the PowerPoint Object Model
         ' 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 oPPShape As Object
        Dim oPPSlide As Object
        Dim mySlides As Variant
        Dim myCharts As Variant
        Dim i As Long
        mySlides = Array(2, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14)
        myCharts = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
         
         ' Reference existing instance of PowerPoint
        Set PPApp = GetObject(, "Powerpoint.Application")
         ' Reference active presentation
        Set PPPres = PPApp.ActivePresentation
        PPApp.ActiveWindow.ViewType = ppViewSlide
         
         'Copy "Chart 1" on "Sheet1" to Slide # 2
         ' Copy "Chart 1" on "Sheet1" as a picture
      For i = LBound(myCharts) To UBound(myCharts)
        ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart" & myCharts(i)).CopyPicture
         ' Paste chart to Slide # 2
        With PPPres.Slides(mySlides(i)).Shapes.Paste
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
           If i = 0 Then 'Special case, only on first slide.
            Set oPPShape = oPPSlide.Shapes(1)
             '~~> Write to the shape
            
            'Range("C2:C5") is not valid, must be a single cell or string. What do you want?
            'oPPShape.TextFrame.TextRange.Text = _
            ActiveWorkbook.Sheets("Sheet1").Range("C2:C5").Value
          End If
        End With
      Next i
             ' Clean up
            Set PPSlide = Nothing
            Set PPPres = Nothing
            Set PPApp = Nothing
    End Function
    In the future, please use CODE Tags. The Editor # Icon will insert Code Tags. You can insert them and paste your code between them, select your code in the editor and the Icon will insert the Tags around the selection, or manually type the Tags as needed.

    Note that I don't work with PP, but VBA code is VBA code.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #7
    Thanks, all I need to add a Text from 3 cells (D3, D4, D5) into a text a box right after a copy the chart in the slide. Can you help? I am struggling to find the right way to do it.

  8. #8
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    myText = Range("D3") & Range("D4") & Range("D5")
    
    With Range("D3:D5")
    myText = .Cells(1) & .Cells(2) &.Cells(3) 
    End With
    
    For Each Cel in Range("D3:D5")
    myText = mytext & Cel
    Next Cel
    
    For i = 3 to 5
    myText = myText &  Range("D" & i)
    Next i
    It would HUHY, (Help Us Help You,) if you posted the code you are using when you ask for help.

    You see, I don't know if you are using the code I posted, or if you fixed the code you were trying, or if you found some code somewhere else that is totally different from both the previous
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  9. #9
    Sorry for not specifying, I have not modified the the code as later I need to add more sheets and graphs.

    If you can help to get the text copy to pp right after the charts is save I will really appreciate it. As will have different cells to copy depending on the slides. I inserted your code, but I guess there is something missing as there is nothing copying to power point.

    Thanks in advance for your help.
    Sub Open_PowerPoint_Presentation()'Opens a PowerPoint Document from Excel
    
    
    Dim objPPT As Object
    Dim PPPres As PowerPoint.Presentation
    Dim PPApp As PowerPoint.Application
    Dim Name As Variant
    
    
    
    
    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    objPPT.Presentations.Open "C:\Users\jose_jimenez2\Documents\test\test.ppt"
    Set PPApp = GetObject(, "Powerpoint.Application")
    Set PPPres = PPApp.ActivePresentation
    copy_chart "sheet1", 2  ' Name of the sheet to copy graph and slide number the graph is to be pasted in
    
    
    Sheets("Sheet1").Select
    Range("P1").Select
    Name = Cells(1, 16)
    
    
    
    
    
    
    If Name = 1 Then
    
    
    With PPPres
            .SaveAs "C:\Users\jose_jimenez2\Documents\test\test1\test1.ppt"
    End With
      Else
    
    
    If Name = 2 Then
    With PPPres
            .SaveAs "C:\Users\jose_jimenez2\Documents\test\test2\test2.ppt"
    End With
      Else
      
      If Name = 3 Then
    With PPPres
            .SaveAs "C:\Users\jose_jimenez2\Documents\test\test3\test3.ppt"
            
    End With
      Else
       End If
      End If
     End If
     
    ' Set PPSlide = Nothing
    'Set PPPres = Nothing
    'Set PPApp = Nothing
    
    
    End Sub
    
    
    Public Function copy_chart(sheet, slide)
    
    
    ' Uses Early Binding to the PowerPoint Object Model
        ' Set a VBE reference to Microsoft PowerPoint Object Library
        Dim PPApp  As PowerPoint.Application
        Dim PPPres As PowerPoint.Presentation
        Dim PPSlide As PowerPoint.slide
        
            
        
            ' Reference existing instance of PowerPoint
            Set PPApp = GetObject(, "Powerpoint.Application")
            ' Reference active presentation
            Set PPPres = PPApp.ActivePresentation
            PPApp.ActiveWindow.ViewType = ppViewSlide
            
    'Copy "Chart 1" on "Sheet1" to Slide # 2
            ' Copy "Chart 1" on "Sheet1" as a picture
            ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 1").CopyPicture
            ' Paste chart  to Slide # 2
            With PPPres.Slides(2).Shapes.Paste
                ' Align pasted chart
                '.Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
        
      myText = Range("C2") & Range("C3") & Range("C4")
     
    With Range("C2:C4")
        myText = .Cells(1) & .Cells(2) & .Cells(3)
    End With
     
    For Each Cel In Range("C2:C4")
        myText = myText & Cel
    Next Cel
     
    For i = 2 To 4
        myText = myText & Range("D" & i)
    Next i
    
    
      
          End With
            
    'Copy "Chart 2" to from "Sheet1" to Slide #
            ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 2").CopyPicture
            ' Paste chart  to Slide # 4
            With PPPres.Slides(4).Shapes.Paste
                ' Align pasted chart
               ' .Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
            
            End With
            
      'Copy "Chart 3" to from "Sheet1" to Slide # 5
            ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 3").CopyPicture
            ' Paste chart  to Slide # 4
            With PPPres.Slides(5).Shapes.Paste
                ' Align pasted chart
                '.Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
            
            End With
     
      'Copy "Chart 4" to from "Sheet1" to Slide # 6
           ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 4").CopyPicture
            ' Paste chart  to Slide # 4
            With PPPres.Slides(6).Shapes.Paste
                ' Align pasted chart
                '.Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
            
            End With
            
      'Copy "Chart 5" to from "Sheet1" to Slide # 7
           ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 5").CopyPicture
            ' Paste chart  to Slide # 4
            With PPPres.Slides(7).Shapes.Paste
                ' Align pasted chart
                '.Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
            
            End With
            
     'Copy "Chart 6" to from "Sheet1" to Slide # 8
           ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 6").CopyPicture
            ' Paste chart  to Slide # 4
            With PPPres.Slides(8).Shapes.Paste
                ' Align pasted chart
                '.Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
            
            End With
            
     'Copy "Chart 7" to from "Sheet1" to Slide # 9
           ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 7").CopyPicture
            ' Paste chart  to Slide # 4
            With PPPres.Slides(9).Shapes.Paste
                ' Align pasted chart
                '.Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
            
            End With
            
      'Copy "Chart 8" to from "Sheet1" to Slide # 10
           ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 8").CopyPicture
            ' Paste chart  to Slide # 4
            With PPPres.Slides(10).Shapes.Paste
                ' Align pasted chart
                '.Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
            
            End With
            
      'Copy "Chart 9" to from "Sheet1" to Slide # 12
           ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 9").CopyPicture
            ' Paste chart  to Slide # 4
            With PPPres.Slides(12).Shapes.Paste
                ' Align pasted chart
                '.Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
            
            End With
            
            
    'Copy "Chart 10" to from "Sheet1" to Slide # 13
           ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 10").CopyPicture
            ' Paste chart  to Slide # 4
            With PPPres.Slides(13).Shapes.Paste
                ' Align pasted chart
                '.Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
            
            End With
            
     'Copy "Chart 11" to from "Sheet1" to Slide # 14
           ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 11").CopyPicture
            ' Paste chart  to Slide # 4
            With PPPres.Slides(14).Shapes.Paste
                ' Align pasted chart
                '.Align msoAlignCenters, True
                '.Align msoAlignMiddles, True
            .LockAspectRatio = msoFalse
            .Width = 534.9034263959
            .Height = 165.5603448276
            .Left = 0
            .Top = 34.2786890756
            
            End With
            
            
            
            ' Clean up
            Set PPSlide = Nothing
            Set PPPres = Nothing
            Set PPApp = Nothing
        End Function

  10. #10
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I have corrected the code and I can copy and paste the char to power point with specific size and position, but I have more charts to copy to an specific slide number, how can I set up the chart number from Excel to the Slide number on the power point>
    Do you understand how the code in Post #6 works? It answers that issue

    These next 3 quotes all say something different. close to the same, but not the same.
    I need to add a Text from 3 cells (D3, D4, D5) into a text a box right after a copy the chart in the slide.
    f you can help to get the text copy to pp right after the charts is save I
    As will have different cells to copy depending on the slides
    Do you understand what the code in Post #8 is doing?



    I know that it is hard with the different languages, but don't quit. We will get it to work.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  11. #11
    Thanks Sa
    Posts previous to 8 were codes that were corrected and I was posting them with other doubts. As of now, I have the code to copy the chart from Excel to power point on the desired slide and with the size/position desired.

    The code on post number 8 I understand it gets the data from Excel and save it in "myText", but I did not find the way to copy into power point. in Post # 9, I added in one of the slides steps right after the chart is copied, but i believe is missing the code to copy to PowerPoint.

Posting Permissions

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