I have been working on a lot of MS-Excel macros and I am going to share one small tutorial on how to copy and paste an image/picture from an excel sheet to power point presentation. Following is the VBA code to carry out the same. Copy and paste the code in the VBE (Visual Basic Editor) of your MS-Excel workbook, which can be accessed by pressing Alt+F11. Or download the file I created for this, Enable Macros by clicking Options (which appears near the formula bar) as soon as you open the file and click on Try Me command button.
Public Sub Export_Excel_Picture_to_PowerPoint() 'Assign False to AddingSlides variable if you don`t want to end an extra slide Dim AddingSlides As Boolean AddingSlides = True 'Requires a reference to the Microsoft PowerPoint Library via the Tools - Reference menu in the VBE Dim ppApp As PowerPoint.Application Dim ppSlide As PowerPoint.Slide Application.ScreenUpdating = False 'Look for existing instance On Error Resume Next Set ppApp = GetObject(, "PowerPoint.Application") On Error GoTo 0 'Create new instance if no instance exists If ppApp Is Nothing Then Set ppApp = New PowerPoint.Application End If 'Add a presentation if none exists If ppApp.Presentations.Count = 0 Then ppApp.Presentations.Add End If 'Make the instance visible ppApp.Visible = True 'Check that a slide exits, if it doesn't add 1 slide. Else use the last slide for the paste operation If ppApp.ActivePresentation.Slides.Count = 0 Then Set ppSlide = ppApp.ActivePresentation.Slides.Add(1, ppLayoutBlank) Else If AddingSlides Then 'Appends slides to end of presentation and makes last slide active ppApp.ActivePresentation.Slides.Add ppApp.ActivePresentation.Slides.Count + 1, ppLayoutBlank ppApp.ActiveWindow.View.GotoSlide (ppApp.ActivePresentation.Slides.Count) Set ppSlide = ppApp.ActivePresentation.Slides(ppApp.ActivePresentation.Slides.Count) Else 'Sets current slide to active slide Set ppSlide = ppApp.ActiveWindow.View.Slide End If End If 'Activate the Excel Sheet and copy the concerned picture from it. 'You may need to change the details here as per the workbook you need to open, the sheet and the picture name Workbooks("Sample.xlsm").Activate Sheets("Sheet2").Select ActiveSheet.Shapes("Picture 1").CopyPicture 'pasting the picture ppSlide.Shapes.Paste.Select 'Adjusting the chart on the slide ppApp.ActiveWindow.Selection.ShapeRange.ScaleWidth 1, msoFalse, msoScaleFromTopLeft ppApp.ActiveWindow.Selection.ShapeRange.ScaleHeight 1, msoFalse, msoScaleFromTopLeft ppApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, msoTrue ppApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, msoTrue Sheets("Sheet1").Select Application.ScreenUpdating = True End Sub
There is the code, which is simple to understand. Please feel free to comment and ask your queries.