user2862496
user2862496

Reputation: 247

VBA error : Invalid enumeration type

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 "Invalid enumeration type". The error is in the line PPApp.ActiveWindow.ViewType = ppViewSlide. Kindly help.

  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

Upvotes: 0

Views: 3783

Answers (1)

L42
L42

Reputation: 19727

If you are Late Binding, you need to replace all your PPt constants with its numeric value.

PPApp.ActiveWindow.ViewType = 1 '~~> equivalent of ppViewSlide

Upvotes: 1

Related Questions