Guest User

Untitled

a guest
Apr 24th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. Sub Open_PowerPoint_Presentation()
  2.  
  3. Dim objPPT As Object
  4. Dim PPTPrez As Object
  5. Dim pSlide As Object
  6. Dim myShape As Object
  7. Dim fileNameString As String
  8. Dim PicCount As Long
  9. Dim i As Long
  10. Dim fileN As String
  11.  
  12.  
  13.  
  14. Set objPPT = CreateObject("PowerPoint.Application")
  15. objPPT.Visible = True
  16.  
  17. Sub Open_PowerPoint_Presentation()
  18.  
  19. Dim objPPT As Object
  20. Dim PPTPrez As Object
  21. Dim pSlide As Object
  22. Dim myShape As Object
  23. Dim fileNameString As String
  24. Dim PicCount As Long
  25. Dim i As Long
  26. Dim fileN As String
  27.  
  28.  
  29.  
  30. Set objPPT = CreateObject("PowerPoint.Application")
  31. objPPT.Visible = True
  32.  
  33. Application.ScreenUpdating = False
  34. For i = 2 To 12
  35. Worksheets("Info").Cells(3, 2) = Worksheets("Temp").Cells(5, i)
  36. Worksheets("Info").Cells(4, 2) = Worksheets("Temp").Cells(6, i)
  37. Worksheets("Info").Cells(5, 2) = Worksheets("Temp").Cells(7, i)
  38. Worksheets("Info").Cells(6, 2) = Worksheets("Temp").Cells(8, i)
  39. Worksheets("Info").Cells(3, 3) = Worksheets("Temp").Cells(10, i)
  40. Worksheets("Info").Cells(4, 3) = Worksheets("Temp").Cells(11, i)
  41. Worksheets("Info").Cells(5, 3) = Worksheets("Temp").Cells(12, i)
  42. Worksheets("Info").Cells(6, 3) = Worksheets("Temp").Cells(13, i)
  43.  
  44. fileN = Worksheets("Temp").Cells(4, i)
  45. Set PPTPrez = objPPT.Presentations.Open("C:Site Reports" & fileN & ".pptx")
  46. Set rng = Worksheets("Info").Range("A2:C6")
  47. Set pSlide = PPTPrez.Slides(6)
  48.  
  49. For PicCount = PPTPrez.Slides(6).Shapes.Count To 1 Step -1
  50. If PPTPrez.Slides(6).Shapes(PicCount).Type = msoPicture Then
  51. PPTPrez.Slides(6).Shapes(PicCount).Delete
  52. End If
  53. Next
  54.  
  55. 'Table
  56. rng.Copy
  57. pSlide.Shapes.PasteSpecial DataType:=2
  58. Set myShape = pSlide.Shapes(pSlide.Shapes.Count)
  59.  
  60. 'Set position:
  61. myShape.Left = 36
  62. myShape.Top = 175
  63. myShape.Height = 150.23
  64. fileNameString = "C:Site Reports" & fileN & ".pptx"
  65. PPTPrez.SaveAs fileNameString
  66. PPTPrez.Close
  67. objPPT.Quit
  68.  
  69. Next i
  70. Application.ScreenUpdating = True
Add Comment
Please, Sign In to add comment