This is how my code looks like: (It's incomplete because I'm still in the process of writing it)

Sub CreateNewPresentation()

    Dim ppApp As PowerPoint.Application
    Dim ppPres As PowerPoint.Presentation
    Dim ppSlide As PowerPoint.Slide
    Dim ppTextbox As PowerPoint.Shape
    
    Set ppApp = New PowerPoint.Application 'starts running powerpoint as background task
    
    ppApp.Visible = msoTrue 'bring it to the front
    ppApp.Activate 'don't get the presentation slides yet, just launching the app
    
    Set ppPres = ppApp.Presentations.Add
    
    Set ppSlide = ppPres.Slides.Add(1, ppLayoutTitle)
    
    ppSlide.Shapes(1).TextFrame.TextRange = "First Quarter Report"
    ppSlide.Shapes(2).TextFrame.TextRange = "Yardbarker"
    
    Set ppSlide = ppPres.Slides.Add(2, ppLayoutBlank)
    ppSlide.Select
    
    'Range("B2").CurrentRegion.Copy


    ThisWorkbook.ActiveSheet.Range("B2").CurrentRegion.Copy
    
    ppSlide.Shapes.Paste.Select
    ppSlide.Shapes(1).Width = ppPres.PageSetup.SlideWidth
    ppSlide.Shapes(1).Left = 0
    
    ppSlide.Shapes(1).Top = (ppPres.PageSetup.SlideHeight / 2) - (ppSlide.Shapes(1).Height / 2)
    
    'add custom text box to the slides
    Set ppTextbox = ppSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 20, ppPres.PageSetup.SlideWidth, 60)

End Sub
However, when I run it, I face a few problems with the code that I just can't properly debug.

  • My editor doesn't recognise PasteSpecial as a function and I am unable to paste my excel table as an OLEobject.
  • The table that I paste as an object disappears in powerpoint when I add additional codes to it:

 ppSlide.Shapes(1).Width = ppPres.PageSetup.SlideWidth
    ppSlide.Shapes(1).Left = 0
    
    ppSlide.Shapes(1).Top = (ppPres.PageSetup.SlideHeight / 2) - (ppSlide.Shapes(1).Height / 2)
  • My code for custom text box doesn't work, even though it worked in the online tutorial I was following. The error message I got was: Runtime error 5. Invalid procedure call or argument.


I'm very new to vba coding and coding in general, to be honest. Would really appreciate if somebody could help me out. I'm using Office for Mac 2011.