VBAWannabee2
New Member
- Joined
- Feb 23, 2022
- Messages
- 28
- Office Version
- 2010
- Platform
- Windows
Hi all!
My concern is what exactly the thread title is.
This is the code that I used to copy excel data then paste it on PPT but it starts the loop at the very last sheet.
Why is that? Appreciate the help in advance!
My concern is what exactly the thread title is.
This is the code that I used to copy excel data then paste it on PPT but it starts the loop at the very last sheet.
Why is that? Appreciate the help 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 = 66
'sh.Left = 152
sh.LockAspectRatio = msoFalse
sh.ScaleHeight 1.24, msoTrue, msoScaleFromMiddle
sh.ScaleWidth 1.33, msoTrue, msoScaleFromMiddle
End If
Next ws
MsgBox "Process done!"
End Sub