title: VBA for Inserting a chart into a ppt slide
body: <p>Below is a procedure that I use to pull charts into a ppt from excel spreadsheets. However one thing I cannot figure out is how to insert the picture into the "object" instead of just pasting it onto th screen. (ie if I did a ppLayoutFourObjects, and sent fours charts to this slide, before adding another, I need to know how to paste the chart into each designated rectangle shown from the 4 Objects selection). I know that the first one seems to always be rectangle five, I can't get the code right. Please help.
   This is all 2003 Office.</p>
  
  <pre><code>sub xls2ppt()
  'I use this to pull charts into ppt from excel   
  Dim xlApp As Object
  Dim xlWrkBook As Object
  Dim lCurrSlide As Long
  Set xlApp = CreateObject("Excel.Application")
  ' Open the Excel workbook
  Set xlWrkBook = xlApp.Workbooks.Open("X:\Users\Admin\Desktop\Budget Overview.xls")
  ' Copy picture of the 1st chart object onto the clipboard
  xlWrkBook.Worksheets(2).ChartObjects(1).CopyPicture
  ' Get the slide number
  lCurrSlide = ActiveWindow.Selection.SlideRange.SlideNumber
  ' Paste the picture onto the PowerPoint slide.
  ActivePresentation.Slides(lCurrSlide).Shapes.Paste
  ' Close the open workbook without saving changes
  xlWrkBook.Close (False)
  xlApp.Quit
  Set xlApp = Nothing
  Set xlWrkBook = Nothing
  End Sub
  </code></pre>
  
  <p>Thanks for any help. VBA for PowerPoint is my weakest, but I am really in need to pick it up for work! Thanks guys!</p>