VBA - Opening PowerPoint from Excel on a Mac

rilzniak

Active Member
Joined
Jul 20, 2012
Messages
288
Hey friends,

What am I doing wrong? Losing it over here...


VBA Code:
Dim PPT As PowerPoint.Application
Dim PP_File As PowerPoint.Presentation
Dim PPT_Path As String

If Not Application.OperatingSystem Like "*Mac*" Then
    PPT_Path = "C:\Users\" & Environ("username") & "\Desktop\MSICP-IFA-Branded-Template - FOR AUTOMATION.pptx"
Else
    PPT_Path = "Macintosh HD/Users/" & Environ("USER") & "/Desktop/MSICP-IFA-Branded-Template - FOR AUTOMATION.pptx"
End If

Set PPT = New PowerPoint.Application
Set PP_File = PPT.Presentations.Open(Filename:=PPT_Path, ReadOnly:=msoFalse)

The code errors out on the last line. Any help or suggestions are appreciated.

-rilzniak
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi

When I try in Office version 16.57 (beta channel) the code crashes Excel on the last line. It appears to be a bug. I reported it to Microsoft. You should too using the Help menu's Feedback option and choose I Don't Like Something.
 
Upvote 0
Hi

When I try in Office version 16.57 (beta channel) the code crashes Excel on the last line. It appears to be a bug. I reported it to Microsoft. You should too using the Help menu's Feedback option and choose I Don't Like Something.
Hi Jim,

Thanks for giving it a shot. I was dumbfounded as to why it was working on my computer but not on my client's - he uses a Mac.

Oddly enough, the code doesn't trip on that line any more (no idea why) but now gets hung up on these lines:


VBA Code:
    ThisWorkbook.Sheets(1).Range("BK5:BO7").CopyPicture
    PP_File.Slides(9).Shapes.PasteSpecial ppPasteEnhancedMetafile
    With PP_File.Slides(9).Shapes("Picture 6")
        .Left = 5
        .Top = 100
    End With

When he clicks 'Debug' the PasteSepcial argument is highlighted. Any idea why? I read online that it's not possible to copy a range from Excel and paste it in PowerPoint, which is why I'm copying it as a picture (I believe). Do I have to add a step to copy/paste that first line as a picture first instead of all in one row?

I don't know enough about running VBA on a Mac (obviously, haha).

Ryan
 
Upvote 0
This works to copy and paste a cell range as a picture in Excel. You should be able to switch to PowerPoint and paste as well

VBA Code:
Sub Macro2()
'Dim mgImage
Set rngImage = Range("C3:C5")
rngImage.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
    ActiveSheet.Paste
End Sub
 
Upvote 0
This works to copy and paste a cell range as a picture in Excel. You should be able to switch to PowerPoint and paste as well

VBA Code:
Sub Macro2()
'Dim mgImage
Set rngImage = Range("C3:C5")
rngImage.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
    ActiveSheet.Paste
End Sub
Hi Jim,

Thanks for your reply and suggestion. I'll give that an attempt and report back with the results.

FYI, I modified the code slightly from xlBitmap -> xlPicture as the font and cell are white so it wasn't showing up in Bitmap format when copy/pasted.

Ryan
 
Upvote 0
Hi Jim,

Thanks for your reply and suggestion. I'll give that an attempt and report back with the results.

FYI, I modified the code slightly from xlBitmap -> xlPicture as the font and cell are white so it wasn't showing up in Bitmap format when copy/pasted.

Ryan
So, I tried altering my code and now PowerPoint and Word both crash. This is really annoying...

Any other suggestions? Could it be a version issue?

Ryan
 
Upvote 0
Could be a bug. Use the Help menu in each affected app and choose Feedback > I Don't Like Something to alert Microsoft to this problem.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

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