문제

Access의 그래프에서 PowerPoint를 프로그래밍 방식으로 작성하려고합니다. 이상적으로, 그래프가 PowerPoint로 이동하면 여전히 액세스 데이터에 연결된 그래프가 아닌 정적 사진이됩니다.

다음과 같은 절차를 시도했습니다.

 Private Sub Command1_click()
     Dim pwrpnt as Object
     Dim Presentation as Object

     set pwrpnt = CreateObject("Powerpoint.Application")
     pwrpnt.Activate
     Set Presentation = pwrpnt.Presentation.Open("C:\test.ppt")
     Me.Graph1.SetFocus
     Runcommand acCmdcopy

     Presentation.Slides(1).Shapes.Paste
     set pwrpnt = Nothing
     set Presentation = Nothing
End Sub

그리고 페이스트 메소드가 실패한 오류 메시지가 나타납니다.

더 나은 접근 방식이 있습니까? 그리고 정적 이미지가 될 수 있습니까?

고맙습니다.

도움이 되었습니까?

해결책

좋아, 나는 그것을 할 방법을 찾았다. 누군가가 더 우아한 방법을 가지고 있다면 여전히 관심이 있지만 다른 사람에게는 비슷한 문제를 다루는 사람에게도 관심이 있습니다.

Private Sub Command1_click()
 'Note: Sample only, in real code this should probably have something to save the 
 'PPT file and then close the powerpoint application, not to mention some error handling,
 ' and possibly some picture formatting, etc.  

 Dim pwrpnt as PowerPoint.Application
 Dim Presntation as PowerPoint.Presentation

 Me.Graph0.Action = acOLECopy
 set pwrpnt = CreateObject("Powerpoint.Application")
 pwrpnt.Activate
 Set Presentation = pwrpnt.Presentations.Open("TemplateFile.ppt")
 pwrpnt.ActiveWindow.ViewType = ppViewSlide

 'This inserts it as a picture, just use .Paste to insert it as an actual chart.
 pwrpnt.ActiveWindow.View.PasteSpecial ppPasteEnhancedMetafile 
EndSub

다른 팁

그렇습니다. 이것은 내가 사용하는 기술입니다. 그리고 솔루션을 위해 웹을 검색하는 데 며칠을 보냈습니다. 그다지 우아하지는 않지만 작동하며 좋은 점은 사용자가 자신의 스타일, 템플릿 등을 쉽게 적용 할 수 있도록 PowerPoint에서 MS 그래프 객체를 얻는 것입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top