Cycle thru Worksheets, Copy Range from Sheet As Image, Create PPT, Paste each image to new ppt slide

BrianExcel

Well-known Member
Joined
Apr 21, 2010
Messages
975
I have a Excel workbook that I am 99% complete on. The steps it performs are:


  1. Opens PPT (successful)
  2. Creates Presentation in Normal View (Successful)
  3. Creates Slide (Successful)
  4. Copies Range from Active (1st) Sheet (successful)
  5. Pastes range from (1st) sheet to slide 1 (successful)
  6. Cycles to 2nd worksheet (successful)
  7. Creates second slide in PPT (successful)
  8. Pastes NEW image of same range on new slide (unsuccessful)

Basically, it is just re-copying the range from sheet 1 instead of looking at sheets 2, 3, 4, etc. I cannot figure out what I am doing wrong. Any thoughts? here is the code.

Code:
Sub CommandButton3_Click()Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PPPic As Variant
Dim wb As Workbook, ws As Worksheet




Set PPApp = CreateObject("Powerpoint.Application")
PPApp.Visible = True
Set PPPres = PPApp.Presentations.Add



For Each ws In ThisWorkbook.Worksheets
    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
            
    ActiveSheet.Range("B2:S34").Select
    Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture 'copy range as picture from worksheet
            
            'PPPres.Slides(j).Select
            Set PPPic = PPPres.Slides(1).Shapes.Paste

Next ws





' Quit PowerPoint
'PPApp.Quit


' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing


End Sub

Thanks!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Add this line...

Code:
[B]ws.select[/B]
    ActiveSheet.Range("B2:S34").Select
    Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture 'copy range as picture from worksheet
 
Upvote 0
One line.

One. ****. Line. LOL.

Thank you Alpha.

One last question - right now, since this is the first time it's working, I see it's actually inserting the last sheet first and the first sheet last in the ppt file, any way to reverse that order?
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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