Hi all,
I have the following code setup to push some charts over to a PPT Template. I want to add some code to find/replace "Customer Name" in the entire deck with whatever is in cell B2 of Sheet1.
Sub Presentation()
Dim ppt As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim pptCL As PowerPoint.CustomLayout
Dim pptShp As PowerPoint.Shape
Dim strPptTemplatePath As String
Dim cht As Chart
Dim ws As Worksheet
Dim i As Long
strPptTemplatePath = GetFolder()
Set ppt = CreateObject("PowerPoint.Application")
ppt.Visible = msoTrue
Set pptPres = ppt.Presentations.Open(strPptTemplatePath, untitled:=msoTrue)
'Copy "Chart 2" on "Sheet3" to Slide # 10
' Copy "Chart 2" on "Sheet3" as a picture
ActiveWorkbook.Sheets("Count by Category").ChartObjects("Chart 1").Chart.ChartArea.Copy
' Paste chart to Slide # 10
With pptPres.Slides(10).Shapes.PasteSpecial(ppPasteShape)
' Align pasted chart
'.Align msoAlignCenters, True
'.Align msoAlignLefts, True
End With
'Copy "Chart 1" on "Sheet14" to Slide # 11
' Copy "Chart 1" on "Sheet14" as a picture
ActiveWorkbook.Sheets("Count by Month").ChartObjects("Chart 1").Chart.ChartArea.Copy
' Paste chart to Slide # 11
With pptPres.Slides(11).Shapes.PasteSpecial(ppPasteShape)
' Align pasted chart
'.Align msoAlignCenters, True
'.Align msoAlignLefts, True
End With
'Copy "Chart 1" to from "Sheet4" to Slide # 12
' Copy "Chart 1" on "Sheet4" as a picture
ActiveWorkbook.Sheets("Category by Month (Full)").ChartObjects("Chart 1").Chart.ChartArea.Copy
' Paste chart to Slide # 12
With pptPres.Slides(12).Shapes.PasteSpecial(ppPasteShape)
' Align pasted chart
'.Align msoAlignCenters, True
'.Align msoAlignMiddles, True
End With
' Clean up
Set pptSld = Nothing
Set pptPres = Nothing
Set ppt = Nothing
End Sub
NOTE: There are 12 times of the 'Copy "Chart 1" to_ _ _Slide # 10
Feel free to simplify my code for the Charts Export!
Bookmarks