convert excel to ppt

Download Convert excel to PPT

If you can't read please download the document

Upload: debi

Post on 07-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Sub ExcelRangeToPowerPoint()'PURPOSE: Copy/Paste An Excel Range Into a New PowerPoint Presentation'NOTE: Must have PowerPoint Object Library Active in Order to Run _ (VBE > Tools > References > Microsoft PowerPoint 12.0 Object Library)'SOURCE: www.TheSpreadsheetGuru.comDim rng As Excel.RangeDim PowerPointApp As PowerPoint.ApplicationDim myPresentation As PowerPoint.PresentationDim mySlide As PowerPoint.SlideDim myShapeRange As PowerPoint.ShapeRange'Copy Range from Excel Set rng = ThisWorkbook.ActiveSheet.Range("A1:D12")'Create an Instance of PowerPoint On Error Resume Next 'Is PowerPoint already opened? Set PowerPointApp = GetObject(class:="PowerPoint.Application") 'Clear the error between errors Err.Clear 'If PowerPoint is not already open then open PowerPoint If PowerPointApp Is Nothing Then Set PowerPointApp = CreateObject(class:="PowerPoint.Application") 'Handle if the PowerPoint Application is not found If Err.Number = 429 Then MsgBox "PowerPoint could not be found, aborting." Exit Sub End If On Error GoTo 0 'Make PowerPoint Visible and Active PowerPointApp.Visible = True PowerPointApp.Activate 'Create a New Presentation Set myPresentation = PowerPointApp.Presentations.Add'Add a slide to the Presentation Set mySlide = myPresentation.Slides.Add(1, ppLayoutTitleOnly)'Copy Excel Range rng.Copy'Paste to PowerPoint and position mySlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile Set myShapeRange = mySlide.Shapes(mySlide.Shapes.Count) 'Set position: myShapeRange.Left = 234 myShapeRange.Top = 186'Clear The Clipboard CutCopyMode = FalseEnd Sub