Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public PowerPointApp As PowerPoint.Application
- Public myPresentation As PowerPoint.Presentation
- Public mySlide As PowerPoint.Slide
- 'in main sub:
- 'Set PowerPointApp = New PowerPoint.Application
- 'Set myPresentation = PowerPointApp.Presentations.Open("C:....")
- Sub SubSlide4(wsKAP As Worksheet, RangeArray As Variant)
- 'RangeArray = = Array("Range1", "Range2", "Range3"...)
- Dim iSlide As Long
- Dim rngVW As Variant
- Dim fullNameVW As String
- Dim ErrorCount4 As Long
- iSlide = 4
- ErrorCount4 = 0
- For Each rngVW In RangeArray 'RangeArray has ~10 members
- 'Paste correct data for each VW
- wsKAP.Range(rngVW).Copy
- wsKAP.Range("tab.StartHeader").PasteSpecial Paste:=xlPasteValues
- fullNameVW = "Test"
- wsKAP.Range("C73") = fullNameVW
- Set mySlide = myPresentation.Slides(iSlide)
- 'Copying Summary for each VW
- Set rng = wsKAP.Range("C89:P97")
- rng.Copy
- DoEvents
- mySlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile
- Set myShape = mySlide.Shapes(mySlide.Shapes.Count)
- With myShape
- .Left = 20
- .Top = 71
- .Height = 92
- End With
- 'Copying Charts
- RepeatOnError: '<-----------------------------------------------------
- Set rng = wsKAP.Range("A30:Y69")
- rng.Copy
- DoEvents
- On Error GoTo ErrorHandler '<-----------------------------------
- mySlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile
- Set myShape = mySlide.Shapes(mySlide.Shapes.Count)
- With myShape
- .Left = 20
- .Top = 187
- .Width = 686
- End With
- iSlide = iSlide + 1
- Application.CutCopyMode = False
- Next rngVW
- ErrorHandler: '<----------------------------------------------------------
- If Err.Number = -2147188160 Then
- If ErrorCount4 > 20 Then
- MsgBox "Too many errors (-2147188160), canceling"
- End
- End If
- ErrorCount4 = ErrorCount4 + 1
- Debug.Print "ErrorCount4 is " & ErrorCount4
- Resume RepeatOnError '<-----------------------------------------
- End If
- On Error GoTo 0
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement