Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. Public PowerPointApp As PowerPoint.Application
  2. Public myPresentation As PowerPoint.Presentation
  3. Public mySlide As PowerPoint.Slide
  4.  
  5. 'in main sub:
  6. 'Set PowerPointApp = New PowerPoint.Application
  7. 'Set myPresentation = PowerPointApp.Presentations.Open("C:....")
  8.  
  9.  
  10. Sub SubSlide4(wsKAP As Worksheet, RangeArray As Variant)
  11. 'RangeArray = = Array("Range1", "Range2", "Range3"...)
  12. Dim iSlide As Long
  13. Dim rngVW As Variant
  14. Dim fullNameVW As String
  15. Dim ErrorCount4 As Long
  16.  
  17. iSlide = 4
  18. ErrorCount4 = 0
  19. For Each rngVW In RangeArray 'RangeArray has ~10 members
  20.  
  21. 'Paste correct data for each VW
  22. wsKAP.Range(rngVW).Copy
  23. wsKAP.Range("tab.StartHeader").PasteSpecial Paste:=xlPasteValues
  24. fullNameVW = "Test"
  25. wsKAP.Range("C73") = fullNameVW
  26.  
  27. Set mySlide = myPresentation.Slides(iSlide)
  28.  
  29. 'Copying Summary for each VW
  30. Set rng = wsKAP.Range("C89:P97")
  31. rng.Copy
  32. DoEvents
  33. mySlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile
  34. Set myShape = mySlide.Shapes(mySlide.Shapes.Count)
  35. With myShape
  36. .Left = 20
  37. .Top = 71
  38. .Height = 92
  39. End With
  40.  
  41. 'Copying Charts
  42. RepeatOnError: '<-----------------------------------------------------
  43. Set rng = wsKAP.Range("A30:Y69")
  44. rng.Copy
  45. DoEvents
  46. On Error GoTo ErrorHandler '<-----------------------------------
  47. mySlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile
  48. Set myShape = mySlide.Shapes(mySlide.Shapes.Count)
  49. With myShape
  50. .Left = 20
  51. .Top = 187
  52. .Width = 686
  53. End With
  54. iSlide = iSlide + 1
  55. Application.CutCopyMode = False
  56. Next rngVW
  57.  
  58. ErrorHandler: '<----------------------------------------------------------
  59. If Err.Number = -2147188160 Then
  60. If ErrorCount4 > 20 Then
  61. MsgBox "Too many errors (-2147188160), canceling"
  62. End
  63. End If
  64.  
  65. ErrorCount4 = ErrorCount4 + 1
  66. Debug.Print "ErrorCount4 is " & ErrorCount4
  67. Resume RepeatOnError '<-----------------------------------------
  68. End If
  69. On Error GoTo 0
  70. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement