Consulting

Results 1 to 3 of 3

Thread: Paste selection to CURRENT PPT Slide

  1. #1

    Paste selection to CURRENT PPT Slide

    This code pastes my current selection from Excel into a new slide on the current PPT presentation I have open. I need it to paste to the current slide I am on rather than a new slide.

    Any advice is greatly appreciated.

    Sub ExcelRangeToPowerPoint()
    
    Dim rng As Range
    Dim PowerPointApp As Object
    Dim myPresentation As Object
    Dim mySlide As Object
    Dim myShape As Object
    
    
      Set rng = Selection
      rng.Copy
    
    
      On Error Resume Next
        
          Set PowerPointApp = GetObject(class:="PowerPoint.Application")
        
          Err.Clear
    
    
          If PowerPointApp Is Nothing Then Set PowerPointApp = CreateObject(class:="PowerPoint.Application")
        
          If Err.Number = 429 Then
            MsgBox "PowerPoint could not be found, aborting."
            Exit Sub
          End If
    
    
      On Error GoTo 0
    
    
      
      Set myPresentation = PowerPointApp.ActivePresentation
      
      Set mySlide = myPresentation.Slides.Add(1, 11) '11 = ppLayoutTitleOnly 'THIS IS WHAT I NEED HELP WITH
    
    
    
    
      mySlide.Shapes.PasteSpecial DataType:=2  '2 = ppPasteEnhancedMetafile
      Set myShape = mySlide.Shapes(mySlide.Shapes.Count)
    
    
          myShape.Left = 66
          myShape.Top = 152
    
    
    
    
      PowerPointApp.Visible = True
      PowerPointApp.Activate
    
    
      Application.CutCopyMode = False
      
    End Sub






    Code listed was modified from -

    https://www.thespreadsheetguru.com/b...point-with-vba

  2. #2
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    Try
    Set mySlide = PowerPointApp.ActiveWindow.View.Slide
    Artik

  3. #3
    Worked perfectly Artik. I was trying that with an s at the end of view for some reason. Regardless thank you for the help!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •