BrianExcel
Well-known Member
- Joined
- Apr 21, 2010
- Messages
- 975
I am using the following code which works really well:
But is one change I'd like to make that I can't seem to put my finger on...
When the PPT is generated and the snapshots are taken and pasted, the last sheet is pasted first, and the first is last. I would like to revert that, so the first slide is pasted first, the second next, etc.
Any thoughts how this could be done?
Code:
Sub CommandButton3_Click()Dim PPApp As PowerPoint.Application, PPPres As PowerPoint.Presentation, PPSlide As PowerPoint.Slide
Dim PPPic As Variant
Dim wb As Workbook, ws As Worksheet
Dim sUser As String, sUserFirst As String, sUserLast As String, sDate As String, sSendUpdate As String
Dim OutApp As Object, OutMail As Object
Dim strbody As String
Dim sPath As String
sSendUpdate = MsgBox("Your file will be generated and saved." & vbNewLine & vbNewLine & "Do you want to email the file when complete?", vbYesNo + vbQuestion)
Application.StatusBar = "Processing file...."
' Create instance of PowerPoint
Set PPApp = CreateObject("Powerpoint.Application")
' For automation to work, PowerPoint must be visible (alternatively, other extraordinary measures must be taken)
PPApp.Visible = True
' Create a presentation
Set PPPres = PPApp.Presentations.Add
For Each ws In ThisWorkbook.Worksheets
If ws.Name = "Template" Then
Else
PPApp.ActiveWindow.ViewType = ppViewNormal 'Choose view of power point you want (slide view, normal view, notes view, etc.)
Set PPSlide = PPPres.Slides.Add(1, ppLayoutBlank) 'Add slide to ppt
ws.Select
ActiveSheet.Range("A1:T35").Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture 'copy range as picture from worksheet
'PPPres.Slides(j).Select
Set PPPic = PPPres.Slides(1).Shapes.Paste
End If
Next ws
'Quit PowerPoint
'PPApp.Quit
'Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Sub
But is one change I'd like to make that I can't seem to put my finger on...
When the PPT is generated and the snapshots are taken and pasted, the last sheet is pasted first, and the first is last. I would like to revert that, so the first slide is pasted first, the second next, etc.
Any thoughts how this could be done?