VBA - PasteSpecial for Mac

ptkk95

New Member
Joined
Aug 28, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. MacOS
As part of a macro that I am writing to copy some ranges in excel and paste them as pictures on powerpoint, I found online the following code:

Set slde = pre.Slides(vSlide_No)
slde.Select
slde.Shapes.PasteSpecial ppPasteBitmap


However, it seems that the PasteSpecialmethod is not present for Mac as I get the error:

Method or data member not found

I am using Excel 2016 on a Mac.
Can anyone help me? Is there a different function for Mac?
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,819
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
I think on a Mac you'd have to use slde.Shapes.Paste but I'm not sure what format you would get.
 

ptkk95

New Member
Joined
Aug 28, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. MacOS
I tried to do this, the code runs but Excel crashes.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,819
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
As in completely disappears?
 

ptkk95

New Member
Joined
Aug 28, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. MacOS

ADVERTISEMENT

Yes. The application shuts down and I am not able to get to the output I want.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,819
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
What's the full code you are using?
 

ptkk95

New Member
Joined
Aug 28, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. MacOS
Here the code, that I got from the following video on youtube:
VBA Code:
'app
'  pre
'   slide
'    shapes
'     text frame
'      text

Sub ExporttoPPT()

'-----------------------------
'Thanks for downloading the code.
'Please visit our channel for a quick explainer on this code.
'Feel free to update the code as per your need and also share with your friends.
'Download free codes from http://vbaa2z.blogspot.com
'Subscribe channel: youtube.com/vbaa2z
'Author: L Pamai (vbaa2z.team@gmail.com)
'-----------------------------

Dim ppt_app As New PowerPoint.Application
Dim pre As PowerPoint.Presentation
Dim slde As PowerPoint.Slide
Dim shp As PowerPoint.Shape
Dim wb As Workbook
Dim rng As Range

Dim vSheet$
Dim vRange$
Dim vWidth As Double
Dim vHeight As Double
Dim vTop As Double
Dim vLeft As Double
Dim vSlide_No As Long
Dim expRng As Range

Dim adminSh As Worksheet
Dim cofigRng As Range
Dim xlfile$
Dim pptfile$


Application.DisplayAlerts = False

Set adminSh = ThisWorkbook.Sheets("Admin")
Set cofigRng = adminSh.Range("Rng_sheets")

xlfile = adminSh.[excelPth]
pptfile = adminSh.[pptPth]
      
Set wb = Workbooks.Open(xlfile)
Set pre = ppt_app.Presentations.Open(pptfile)


For Each rng In cofigRng
   
   '----------------- set VARIABLES
   With adminSh
      vSheet$ = .Cells(rng.Row, 4).Value
      vRange$ = .Cells(rng.Row, 5).Value
      vWidth = .Cells(rng.Row, 6).Value
      vHeight = .Cells(rng.Row, 7).Value
      vTop = .Cells(rng.Row, 8).Value
      vLeft = .Cells(rng.Row, 9).Value
      vSlide_No = .Cells(rng.Row, 10).Value
   End With
   
   
   '----------------- EXPORT TO PPT
   
            wb.Activate
            Sheets(vSheet$).Activate
            Set expRng = Sheets(vSheet$).Range(vRange$)
            expRng.Copy
 
            Set slde = pre.Slides(vSlide_No)
            slde.Select
            slde.Shapes.PasteSpecial ppPasteBitmap
            
            Set shp = slde.Shapes(1)
            
            With shp
               
               .Top = vTop
               .Left = vLeft
               .Width = vWidth
               .Height = vHeight
               
            End With
            
            
            Set shp = Nothing
            Set slde = Nothing
            Set expRng = Nothing
   
   Application.CutCopyMode = False
   Set expRng = Nothing
Next rng

pre.Save
pre.Close

Set pre = Nothing
Set ppt_app = Nothing

wb.Close False
Set wb = Nothing

Application.DisplayAlerts = True

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,118,765
Messages
5,574,108
Members
412,571
Latest member
Ventura7
Top