s.schwantes
08-27-2008, 03:17 PM
:banghead:
I have the following which works for a chart, but I also want to copy in the data that created the chart as a separate table. I've named the range of cells as "Table1". I've tried editing the red line below to this:
Worksheets(1).Range("Table1").Copy
but that doesn't work. :dunno
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
xlWrkBook.Worksheets(1).ChartObjects(1).CopyPicture
' Switch back to PPT
ActiveWindow.View.GotoSlide Index:=1
ActiveWindow.Selection.SlideRange.Shapes.Paste
End Sub
Any ideas ... any one?
Thanks!
I've a follow up question also. The working macro above just dumps the pasted object arbitrarily onto the slide. My slide layout is basically the 4 up format, i.e., I have a title bar and then four boxes for content. I'd like to be able to specify the box into which the chart or table should be pasted. By using the recorder and clicking on (selecting) the boxes, I was able to identify the proper approach, e.g.
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 8").Select
I tried to use this snippet and change "Select" to "Paste" but no luck there. I keep running into method or other errors.
Thanks again,
Steve S.
I have the following which works for a chart, but I also want to copy in the data that created the chart as a separate table. I've named the range of cells as "Table1". I've tried editing the red line below to this:
Worksheets(1).Range("Table1").Copy
but that doesn't work. :dunno
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
xlWrkBook.Worksheets(1).ChartObjects(1).CopyPicture
' Switch back to PPT
ActiveWindow.View.GotoSlide Index:=1
ActiveWindow.Selection.SlideRange.Shapes.Paste
End Sub
Any ideas ... any one?
Thanks!
I've a follow up question also. The working macro above just dumps the pasted object arbitrarily onto the slide. My slide layout is basically the 4 up format, i.e., I have a title bar and then four boxes for content. I'd like to be able to specify the box into which the chart or table should be pasted. By using the recorder and clicking on (selecting) the boxes, I was able to identify the proper approach, e.g.
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 8").Select
I tried to use this snippet and change "Select" to "Paste" but no luck there. I keep running into method or other errors.
Thanks again,
Steve S.