2014-05-12 2 views
0

다음은 Excel에서 시트의 차트를 복사하여 PowerPoint에서 붙여 넣기하는 VBA 기능입니다. 그러나이 코드는 "잘못된 열거 형"오류를 제공합니다. 오류는 PPApp.ActiveWindow.ViewType = ppViewSlide 줄에 있습니다. 친절히 도와주세요. 당신이 Late Binding 경우VBA 오류 : 잘못된 열거 유형

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 
+0

PowerPoint 개체 라이브러리를 참조한 적이 있습니까? 모듈 시작 부분에'Option Explicit'을 가지고 있습니까? – GSerg

+0

왜'GetObject'인가? –

답변

1

, 당신은 그 숫자 값으로 모든 PPT 상수를 교체해야합니다.

PPApp.ActiveWindow.ViewType = 1 '~~> equivalent of ppViewSlide 
관련 문제