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:
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.
Thanks!
- Opens PPT (successful)
- Creates Presentation in Normal View (Successful)
- Creates Slide (Successful)
- Copies Range from Active (1st) Sheet (successful)
- Pastes range from (1st) sheet to slide 1 (successful)
- Cycles to 2nd worksheet (successful)
- Creates second slide in PPT (successful)
- 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!