Hello,
I'm trying to copy charts from an Excel workbook to placeholders in a Powerpoint presentation. Below are the codes I'm using:
I got the error with the
, saying "Can't find project or library". If I remove it, putting only
, then the code works but I cannot keep the format of the chart since my Powerpoint presentation uses a theme.
Could anyone help me get rid of this error?
I'm trying to copy charts from an Excel workbook to placeholders in a Powerpoint presentation. Below are the codes I'm using:
Code:
<code>Sub Pwp()
Dim wb As Workbook
Dim ppt As PowerPoint.Presentation
Dim pptApp As PowerPoint.Application
Dim sld As PowerPoint.Slide
Dim shp As PowerPoint.Shape
Dim pth As String
Dim i As Long
Set wb = ActiveWorkbook
pth = wb.path & "\My Presentation.pptm"
Set pptApp = New PowerPoint.Application
pptApp.Visible = True
pptApp.Presentations.Open Filename:=pth
Set ppt = pptApp.ActivePresentation
For Each sld In ppt.Slides
i = sld.SlideNumber
sld.Select
For Each shp In sld.Shapes
If i = 2 And shp.ID = 6148 Then
shp.TextFrame.TextRange.Text = ""
wb.Activate
Sheets(1).ChartObjects("From2007").Chart.ChartArea.Copy
pptApp.Activate
shp.Select msoCTrue
ppt.Windows(1).View.PasteSpecial (ppPasteMetafilePicture)
End If
Next shp
Next sld
End Sub</code>
I got the error with the
Code:
ppPasteMetafilePicture
Code:
PasteSpecial
Could anyone help me get rid of this error?