Forum Discussion

Benjamin Mark's avatar
Benjamin Mark
Copper Contributor
Sep 03, 2018

Excel VBA crashing in MacOS

I have a simple Excel VBA macro to analyse and manipulate some powerpoint presentations. My code keeps crashing Excel when I run it for some reason. I've narrowed it down to an issue with referring to specific slides. A simplified version of the code, which just opens up a new presentation and adds a couple of blank slides to it, looks like this:

 

Option Explicit

Sub test()

Dim myApp As PowerPoint.Application

Dim myPres As Presentation

Dim mySlide As Slide

Set myApp = CreateObject("PowerPoint.Application")

Set myPres = myApp.Presentations.Add

Set mySlide = myPres.Slides.Add(Index:=1, Layout:=ppLayoutTitleOnly)

Set mySlide = myPres.Slides.Add(Index:=2, Layout:=ppLayoutTitleOnly)

 

' this next line causes a complete crash of Excel

Set mySlide = myPres.Slides(1)

' other code would follow here

 

End Sub

 

I can't work out what's going on. The code runs fine on a PC, so I'm guessing it's something to do with using a Mac. I'm running MacOS High Sierra, and Excel 16.16.1 (and the Powerpoint 16.0 object library). I get the same problem in my more complex full code - Excel crashes every time I try to refer to a specific slide in a presentation. 

 

All help greatly appreciated

 

 

 

  • Benjamin Mark's avatar
    Benjamin Mark
    Copper Contributor

    Bump - I'd be really grateful for some help on this. If somebody could run the code on MacOS and see if it crashes for you too, that would be a great start.

     

    thanks

Resources