Saving a copy of an updated PowerPoint through VBA

Lewisc_97

New Member
Joined
Feb 25, 2019
Messages
4
Hi People,

I have created a script that pastes charts to an existing Powerpoint, however I want the Powerpoint to Save As so I have a new copy. I don't know where to start with this... I have copied my code below. Hopefully this makes sense

Thanks for the help

Lewis

Sub TransferCharts2()
Dim PowerPointApp As Object
Dim myPresentation As Object
Dim mySlide As Object
Dim excelChart As ChartObject
Dim presChart As Object
Dim WS_Count As Integer
Dim I As Integer
Dim Title As String
Dim tb As PowerPoint.Shape



Set PowerPointApp = New PowerPoint.Application

Set myPresentation = PowerPointApp.Presentations.Open("P:\Lewis & Jacob\Lewis\Top Level Automation\Master Powerpoint.pptx")

Application.ScreenUpdating = False

Worksheets(1).Select
Title = Range("C5")
Set mySlide = myPresentation.Slides(1)
Set tb = mySlide.Shapes("Text Placeholder 3")
tb.TextFrame2.TextRange.Characters.Text = Title

WS_Count = ActiveWorkbook.Sheets.Count

For I = 2 To WS_Count
If I < 6 Then
Set mySlide = myPresentation.Slides(I)
' Add Commentary
Worksheets(I).Select

For Each excelChart In ActiveSheet.ChartObjects

excelChart.Chart.ChartTitle.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)

'excelChart.Chart.Axes(xlCategory).TickLabels.Font.Color = RGB(0, 0, 0)

'excelChart.Chart.Axes(xlValue, xlPrimary).TickLabels.Font.Color = RGB(0, 0, 0)

'excelChart.Chart.Axes(xlValue, xlPrimary).AxisTitle.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)

'excelChart.Chart.Axes(xlValue, xlSecondary).TickLabels.Font.Color = RGB(0, 0, 0)

'excelChart.Chart.Axes(xlValue, xlSecondary).AxisTitle.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)

excelChart.Chart.Legend.Font.Color = RGB(0, 0, 0)


excelChart.Copy

mySlide.Shapes.PasteSpecial (ppPasteDeviceIndependentBitmap)

With mySlide
With .Shapes(.Shapes.Count)
.LockAspectRatio = msoTrue
.Left = 9
.Top = 60
.Height = 400
.Width = 700
End With
End With
Next
End If
Next I

PowerPointApp.Visible = True
PowerPointApp.Activate

Application.CutCopyMode = False



End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top