Paste Excel Data to PPT that will cover the whole slide

VBAWannabee2

New Member
Joined
Feb 23, 2022
Messages
28
Office Version
  1. 2010
Platform
  1. Windows
Hi,

Hope y'all doing well.

Just want to ask how can I turn my code below to paste the excel data and it will cover the whole slide in PPT?
And also, why is my loop always starts at the very last sheet of my workbook? Why does it happen?
Thanks in advance!

VBA Code:
Sub CreateNewPres()

    Dim ppt As PowerPoint.Application
    Dim pres As PowerPoint.Presentation
    Dim sh As PowerPoint.ShapeRange
    Dim sl As PowerPoint.Slide
    Dim ws As Worksheet
    
    Set ppt = GetObject(Class:="Powerpoint.Application")
    Set pres = ppt.Presentations("TESTFILE - Copy.pptx")

For Each ws In ActiveWorkbook.Worksheets

If ws.Visible = True Then

    Set sl = pres.Slides.Add(3, ppLayoutBlank)

    ws.Range("A1:D8").Copy

    Set sh = sl.Shapes.PasteSpecial(ppPasteEnhancedMetafile)
    
    'sh.Top = 50
    'sh.Left = 50
    
End If

Next ws

MsgBox "Process done!"

End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,215,096
Messages
6,123,074
Members
449,094
Latest member
mystic19

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