s.schwantes
08-27-2008, 05:39 PM
'Paste Excel TABLE (as a named range) as pictures in PowerPoint (Paste Special)
Sub XlChartPasteSpecial()
Dim xlApp As Object
Dim xlWrkBook As Object
Dim lCurrSlide As Long
Set xlApp = CreateObject("Excel.Application")
' Open the Excel workbook
Set xlWrkBook = xlApp.Workbooks.Open("C:\BOOK1.XLS")
' Copy named range Table1
Dim PasteRange As Boolean
Dim RangePasteType As String
Dim RangeName As String
PasteRange = True
RangeName = "Table1"
RangePasteType = "HTML"
RangeLink = True
xlWrkBook.Worksheets(1).Range("Table1").CopyPicture
' Switch back to PPT
ActiveWindow.View.GotoSlide Index:=1
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 5").Select
Paste
'Paste Excel CHART as pictures in PowerPoint (Paste Special)
Set xlApp = CreateObject("Excel.Application")
' Open the Excel workbook
Set xlWrkBook = xlApp.Workbooks.Open("C:\BOOK1.XLS")
' Copy Chart
xlWrkBook.Worksheets(1).ChartObjects(1).CopyPicture
' Switch back to PPT
ActiveWindow.View.GotoSlide Index:=1
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 8").Select
Paste
End Sub
:help
I've got four text boxes or placeholders on my slide. I want to specify which one to paste the table and chart from Excel into ... as is the macro above breaks on the red lines. If I omit the shape name, change Select to Paste, and delete the next line ... it works, but the objects just get dropped on the slide randomly and are not tied to any shapes. ... ?????
thanks
Steve S
Sub XlChartPasteSpecial()
Dim xlApp As Object
Dim xlWrkBook As Object
Dim lCurrSlide As Long
Set xlApp = CreateObject("Excel.Application")
' Open the Excel workbook
Set xlWrkBook = xlApp.Workbooks.Open("C:\BOOK1.XLS")
' Copy named range Table1
Dim PasteRange As Boolean
Dim RangePasteType As String
Dim RangeName As String
PasteRange = True
RangeName = "Table1"
RangePasteType = "HTML"
RangeLink = True
xlWrkBook.Worksheets(1).Range("Table1").CopyPicture
' Switch back to PPT
ActiveWindow.View.GotoSlide Index:=1
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 5").Select
Paste
'Paste Excel CHART as pictures in PowerPoint (Paste Special)
Set xlApp = CreateObject("Excel.Application")
' Open the Excel workbook
Set xlWrkBook = xlApp.Workbooks.Open("C:\BOOK1.XLS")
' Copy Chart
xlWrkBook.Worksheets(1).ChartObjects(1).CopyPicture
' Switch back to PPT
ActiveWindow.View.GotoSlide Index:=1
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 8").Select
Paste
End Sub
:help
I've got four text boxes or placeholders on my slide. I want to specify which one to paste the table and chart from Excel into ... as is the macro above breaks on the red lines. If I omit the shape name, change Select to Paste, and delete the next line ... it works, but the objects just get dropped on the slide randomly and are not tied to any shapes. ... ?????
thanks
Steve S