Articles

copy excel table with graph to powerpoint

November 26, 2012 at 02:37:51
Specs: Microsoft Windows XP Professional, 2 GHz / 958 MB

Hi..

Please help modify this code. My problem is I want to copy both graph and table
in a worksheet to powerpoint but this code only copies the graph or table. When a
worksheet has a graph and a table it only copies the graph and not the table.

Please do help


Option Explicit

Dim PP As Object
Dim PP_File As Object
Dim PP_Slide As Object
Dim activwksht As Variant
Dim lastsht As Integer
Dim sht As Integer
Dim ReportName As Variant
Dim shpcount As Integer

Sub ExcelToPPT()

    Sheets(1).Activate
    ReportName = Application.GetOpenFilename("Microsoft PowerPoint-files(*.ppt),*.ppt")
    Set PP = CreateObject("Powerpoint.Application")
    PP.Activate
    Set PP_File = PP.Presentations.Open(ReportName)
    PP.Visible = True

    sht = ActiveSheet.Index
    lastsht = Sheets.Count
  
    Do While sht <= lastsht
        activwksht = ActiveSheet.Name
  
        PP.ActiveWindow.View.GotoSlide activwksht 'goto slide that equal to helpfile sheetname
        
        On Error Resume Next
            shpcount = Sheets(activwksht).Shapes.Count
        If shpcount = 0 Then
            Call CopyDataFromExcel
            Call ResizeTabulate
        Else
            Sheets(activwksht).Shapes.SelectAll
            Call CopyGraphFromExcel
            Call ResizeGraph
        End If
            sht = sht + 1
            Sheets(sht).Activate
    Loop
       
End Sub

Sub CopyDataFromExcel()

ActiveSheet.UsedRange.CopyPicture
PP.ActiveWindow.View.PasteSpecial(ppPasteEnhancedMetafile).Select

 
End Sub

Sub CopyGraphFromExcel()


Selection.CopyPicture
PP.ActiveWindow.View.PasteSpecial(ppPasteEnhancedMetafile).Select


End Sub


Thank you.


See More: copy excel table with graph to powerpoint

Reply ↓  Report •

Related Solutions


Ask Question