View Full Version : VBA Code to export Excel to OVERWRITE an EXISTING PowerPoint

08-06-2012, 01:05 AM
Hi all,
I need help! Can anyone tell me how to edit this code so that I can export data I have in Excel to an exisiting PowerPoint file, i.e, I do not want to simply add additional powerpoint slides to an exisiting powerpoint slide package.

Sub ExportToPPT()
Dim ActFileName As Variant
Dim ScaleFactor As Single
On Error GoTo ErrorHandling
ActFileName = Application.GetOpenFilename("Microsoft PowerPoint-Files (*.ppt), *.ppt")
ScaleFactor = Range("myScaleFactor").Value
Set PP = CreateObject("Powerpoint.Application")
If ActFileName = False Then
Set PP_File = PP.ActivePresentation
Set PP_File = PP.Presentations.Open(ActFileName)
End If
PP.Visible = True
CopyandPastetoPPT "myDashboard01", Range("myInputStartTitles").Offset(1, 0).Value, ScaleFactor, ScaleFactor
CopyandPastetoPPT "myDashboard02", Range("myInputStartTitles").Offset(2, 0).Value, ScaleFactor, ScaleFactor
CopyandPastetoPPT "myDashboard03", Range("myInputStartTitles").Offset(3, 0).Value, ScaleFactor, ScaleFactor
Set PP_Slide = Nothing
Set PP_File = Nothing
Set PP = Nothing
Exit Sub
Set PP_Slide = Nothing
Set PP_File = Nothing
Set PP = Nothing
MsgBox "Error No.: " & Err.Number & vbNewLine & vbNewLine & "Description: " & Err.Description, vbCritical, "Error"
End Sub

Kenneth Hobs
08-06-2012, 05:25 AM
Welcome to the forum! Please paste code between VBA code tags. That is a nice feature in this forum. Others just use the CODE tags for code.

You can get an example XLS file at ExcelForum (http://www.excelforum.com/excel-programming-vba-macros/678426-copy-all-sheets-to-an-existing-powerpoint-template.html?p=2884061). Rick probably guessed that I hang out here more than some other forums. If I get time at lunch today or after work, I will look into this if no one here solves it by then.

08-06-2012, 03:41 PM
I thought I would follow up on my intital post to help clarify my issue.

I've attached an excel file with code which exports data to PowerPoint (please note I came across this file whilst searching the internet for a possible solution to my problem).

The code currently exports the excel data to new slides at the end of my existing PowerPoint file. I would rather the export commence on slide 1 of my PowerPoint file and then continue to populate the existing slides I already have,i.e ranges 1, 2 & 3 get exported to slides 1, 2 and 3 respectively (I have 65 ranges to export to their own PowerPoint slide, resulting in 65 PowerPoint slides).