title: VBA error : Invalid enumeration type
body: <p>The following is a VBA function to copy a chart from a sheet in excel and paste it in powerpoint. However, this codes gives an error "<strong>Invalid enumeration type</strong>".
  The error is in the line PPApp.ActiveWindow.ViewType = ppViewSlide.
  Kindly help.</p>
  
  <pre><code>  Public Function copy_chart1(sheet, slide, group_name, ht, wdt, lf, tp)
  
  
  Dim PPApp As Object
  Dim PPPres As Object
  Dim PPSlide As Object
  
  Set PPApp = CreateObject("PowerPoint.Application")
  
  
  Set PPApp = GetObject(, "Powerpoint.Application")
  Set PPPres = PPApp.ActivePresentation
  PPApp.ActiveWindow.ViewType = ppViewSlide
  PPApp.ActiveWindow.View.GotoSlide (slide)
  
  Worksheets(sheet).Activate
  
  ActiveSheet.Shapes(group_name).CopyPicture
  
  
  Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
  With PPSlide
  ' paste and select the chart picture
  .Shapes.Paste.Select
  
      With PPApp.ActiveWindow.Selection.ShapeRange
          .LockAspectRatio = msoFalse
          .Height = ht
          .Width = wdt
          .Left = lf
          .Top = tp
      End With
  End With
  
  
  ' Clean up
  Set PPSlide = Nothing
  Set PPPres = Nothing
  Set PPApp = Nothing
  End Function
  </code></pre>