VBA from Excel to Power Point

thomasuponor

New Member
Joined
Sep 13, 2018
Messages
44
Office Version
  1. 2016
Platform
  1. Windows
Hi, On Excel sheet, I have 2 areas I want to copy to Power Point on 2 different slides.

Current macro works for 1 area but I'm having problem getting it to work with 2 areas.
Capture.PNG


Also asked here VBA from Excel to Power Point

VBA Code:
Sub copyRangeToPresentation()
 
' Open New PowerPoint Instance
Set pptApp = CreateObject("PowerPoint.Application")
 
With pptApp
    ' Create A New Presentation
    Set ppt = .Presentations.Add
    ' Add A Blank Slide
    Set newSlide = ppt.Slides.Add(1, 12) ' ppLayoutBlank = 12
    ' Copy Range from Active Sheet in Excel
    ActiveSheet.Range1("B2:AI26").Copy
    ActiveSheet.Range2("AK2:AW26").Copy
    ' Paste to Powerpoint as an Image
    newSlide.Shapes.PasteSpecial DataType:=2  '2 = ppPasteEnhancedMetafile
    ' Switch to PowerPoint
    .Activate
End With
 
End Sub
 
Last edited by a moderator:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
How about ...

VBA Code:
Sub copyRangeToPresentation()
 
    ' Open New PowerPoint Instance
    Set pptApp = CreateObject("PowerPoint.Application")
    With pptApp
        ' Create A New Presentation
        Set ppt = .Presentations.Add
        With ppt
            ' Add A Blank Slide
            Set newSlide = .slides.Add(1, 12) ' ppLayoutBlank = 12
            ' Copy Range from Active Sheet in Excel
            ActiveSheet.Range("B2:AI26").Copy
            ' Paste to Powerpoint as an Image
            newSlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile
            
            ' Add A Second Blank Slide
            Set newSlide = .slides.Add(.slides.Count + 1, 12) ' ppLayoutBlank = 12
            ' Copy Range from Active Sheet in Excel
            ActiveSheet.Range("AK2:AW26").Copy
            ' Paste to Powerpoint as an Image
            newSlide.Shapes.PasteSpecial DataType:=2 '2 = ppPasteEnhancedMetafile
            ' Switch to PowerPoint
        End With
        .Activate
    End With
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,216,072
Messages
6,128,631
Members
449,460
Latest member
jgharbawi

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