Need to "Reverse" a Piece of Existing Code....

BrianExcel

Well-known Member
Joined
Apr 21, 2010
Messages
975
I am using the following code which works really well:

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?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try replacing this :
Code:
For Each ws In ThisWorkbook.Worksheets
With this:
Code:
 For i = Worksheets.Count To 1 Step -1
        Set ws = Worksheets(i)
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,685
Members
448,977
Latest member
dbonilla0331

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