Copy Excel Range to Existing Powerpoint File and Specific Slide

PDeee

New Member
Joined
Sep 9, 2018
Messages
1
Hi All,

I don't have any knowledge in VBA so can someone help me to generate an Excel range to an existing Powerpoint file and I want to paste it on a specific slide?
I am using 2010 versions. I have checked some of the forums in here but it's not working for me.

I have to copy an excel ranges and paste it in the PPT as a table with colored shape. I have 3 excel ranges to be paste in existing 3 slides of the PPT.

Thanks for the help!

-PD
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
A working starting point
The VBA below:
- creates a new presentation (yes - I know you do not want that :smile: )
- and inserts a range into a slide

Do the following
- create a new worksheet
- add a typical range of values in a contiguous range starting in cell A1
- quicky format that range with borders, bold , colours, to make it look the way you want it to look in powerpoint
- paste the code below into a module and run it

Code:
Sub ExcelRangeToPowerPoint()
'PURPOSE: Copy/Paste An Excel Range Into a New PowerPoint Presentation
'SOURCE: www.TheSpreadsheetGuru.com

Dim rng As Range
Dim PowerPointApp As Object
Dim myPresentation As Object
Dim mySlide As Object
Dim myShape As Object

'Set Range in excel
  Set rng = ThisWorkbook.ActiveSheet.Range("A1").CurrentRegion

'Create an Instance of PowerPoint
  On Error Resume Next
    
    'Is PowerPoint already opened?
    Set PowerPointApp = GetObject(class:="PowerPoint.Application")
    
    'Clear the error between errors
    Err.Clear

    'If PowerPoint is not already open then open PowerPoint
    If PowerPointApp Is Nothing Then Set PowerPointApp = CreateObject(class:="PowerPoint.Application")
    
    'Handle if the PowerPoint Application is not found
    If Err.Number = 429 Then
        MsgBox "PowerPoint could not be found, aborting."
        Exit Sub
    End If

  On Error GoTo 0

'Optimize Code
    Application.ScreenUpdating = False
  
'Create a New Presentation
    Set myPresentation = PowerPointApp.Presentations.Add

'Add a slide to the Presentation
    Set mySlide = myPresentation.Slides.Add(1, 11) '11 = ppLayoutTitleOnly
    
'Copy Excel Range
    rng.Copy

'Paste to PowerPoint and position
    Set mySlide = myPresentation.Slides(1)
    mySlide.Shapes.PasteSpecial DataType:=2  '2 = ppPasteEnhancedMetafile
    Set myShape = mySlide.Shapes(mySlide.Shapes.Count)
  
    'Set position:
    myShape.Left = 66
    myShape.Top = 152

'Make PowerPoint Visible and Active
    PowerPointApp.Visible = True
    PowerPointApp.Activate

'Clear The Clipboard
    Application.CutCopyMode = False
  
End Sub


If you prefer to modify the code yourself have a look at this link and this one too

Or if you want some further help.. what I need to know next
1. what needs modifying? (other than making the VBA update an existing file)
- is range formatted as you want ?
- is table size correct?
- any other issue with it?
2. how are your Excel ranges identified?
- are they a consistent size?
- are they named ranges? (what are the names?)
- are they Excel tables? (table names?)
- etc...
 
Upvote 0

Forum statistics

Threads
1,223,756
Messages
6,174,320
Members
452,555
Latest member
colc007

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