Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. 'declare the variables
  2. Dim activePowerPoint As PowerPoint.Application
  3. Dim activeSlide As PowerPoint.Slide
  4. Dim cht As Excel.ChartObject
  5. Dim rng As Range
  6.  
  7. 'Copy Range from Excel
  8.  
  9. 'Look for existing instance
  10. On Error Resume Next
  11. Set newPowerPoint = GetObject(, "PowerPoint.Application")
  12. On Error GoTo 0
  13.  
  14. 'Show the PowerPoint
  15. newPowerPoint.Visible = True
  16.  
  17. 'Add a new slide where we will paste the chart
  18. newPowerPoint.ActivePresentation.Slides.Add newPowerPoint.ActivePresentation.Slides.Count + 1, ppLayoutText
  19. newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.Count
  20. Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)
  21.  
  22. 'Copy the chart and paste it into the PowerPoint as a Metafile Picture
  23. rng.Copy
  24. activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select
  25.  
  26.  
  27. 'Adjust the positioning of the Chart on Powerpoint Slide
  28. newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 0
  29. newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 0
  30.  
  31. activeSlide.Shapes(2).Width = 200
  32. activeSlide.Shapes(2).Left = 505
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement