Hi,
I am trying to copy a ChartObject created in a workbook sheet and paste it into a powerpoint 2010 slide, such that it becomes a standalone Excel Chart with data (embedded).
When i do it manually i.e :
- Copy ChartObject present in WorkSheet
- Goto Powerpoint Slide
- Click PasteSpecial & select "Use Destination Theme & Embed Workbook (H)".
- Right-click the ChartObject in Powerpoint & click "Edit Data".
Then i get a new standalone workbook with Title "Chart in Microsoft Excel", that shows the Chart as well as data. I have not been able to replicate this scenario where i get a new standalone workbook with Title "Chart in Microsoft Excel" using Excel VBA. Can someone help?
Assuming there is a simple column chart on the sheet, here is the code:
PHP Code:
Option Explicit
Sub doit()
Dim Temp As Workbook
Dim Rng As Range
Dim ChtObj As ChartObject
With ThisWorkbook.Sheets(1)
Set ChtObj = .ChartObjects(1)
With ChtObj
.Copy
End With
Dim ppapp As Object
Dim pppres As Object
Dim ppslide As Object
On Error Resume Next
Set ppapp = GetObject(, "Powerpoint.Application")
If ppapp Is Nothing Then
Set ppapp = CreateObject("Powerpoint.Application")
End If
On Error GoTo 0
Set pppres = ppapp.presentations.Add
Set ppslide = pppres.Slides.Add(1, 12)
With ppapp
.Activate
.Visible = msoTrue
.ActiveWindow.viewtype = 1
End With
ChtObj.Copy
ppapp.ActiveWindow.View.Paste
End With
End Sub
i have tried :
PHP Code:
ppslide.Shapes.PasteSpecial(11, 0, , , , 0) '11 = ppPasteShape
OR
PHP Code:
ppslide.Shapes.PasteSpecial 10, 0, , , , 0 '10 = ppPasteOLEObject
OR
PHP Code:
ppapp.ActiveWindow.View.PasteSpecial 10, 0, , , , 0
but it did not help!
Bookmarks