Excel VBA를 통해 업데이트해야하는 PowerPoint 프레젠테이션이 있는데 차트의 데이터 시트에 데이터를 추가하는 데 방해가됩니다. 코드 밑. 이 작업을 수행하려면 Excel VBA를 통해 PowerPoint 프레젠테이션을 열고 Excel이 열려 있다고 가정하고 거기에서 범위를 가져 와서 DataChart에 붙여 넣습니다.Excel VBA를 사용하여 PowerPoint 데이터 시트 차트 개체 편집
저는 아직 객체에 상당히 익숙하지 않습니다. 파워 포인트 객체에 더 익숙해지기 때문에 거기에 붙여 넣는 방법을 알아낼 수 없습니다. 개체는 msoEmbeddedOLEObject이고 OLEFormat.progID는 슬프게도 이해할 수없는 "MSGraph.Chart.8"입니다.
Public sPath As String, sFile As String, sFilePPT As String
Public PPApp As PowerPoint.Application
Public PPPres As PowerPoint.Presentation
Public PPSlide As PowerPoint.Slide
Public PPShape As PowerPoint.Shape
Public PPChart As PowerPoint.Chart
Public PPChartData As PowerPoint.ChartData
Public cTable As Excel.ListObject
Sub OpenPPT()
sPath = ThisWorkbook.Path & "\"
sFilePPT = "Presentation1.pptx"
On Error Resume Next
'==> Check if PowerPoint is running
Set PPApp = GetObject(, "PowerPoint.Application")
If PPApp Is Nothing Then
'==> If PowerPoint is not running, create new instance
Set PPApp = CreateObject("PowerPoint.Application")
'==> and make it visible (PowerPoint must be visible to be used)
PPApp.Visible = True
Set PPPres = PPApp.Presentations.Open(sPath & sFilePPT)
End If
On Error GoTo 0
'==> Reference presentation and slide
On Error Resume Next
'==> If there's at least one presentation, use it
If PPApp.Windows.Count > 0 Then
Set PPPres = PPApp.ActivePresentation
'==> use active slide
Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
Else
MsgBox "PowerPoint Presentation not found"
Exit Sub
End If
On Error GoTo 0
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Sub
Sub test()
Dim i As Byte
Dim r As Range
Call OpenPPT
Set PPApp = GetObject(, "PowerPoint.Application")
Set PPPres = PPApp.Presentations(1)
Debug.Print PPPres.Name
Set PPSlide = PPPres.Slides(2)
PPSlide.Select
Debug.Print PPSlide.Name
Set PPShape = PPSlide.Shapes(2)
PPShape.Select
If PPShape.OLEFormat.progID = "MSGraph.Chart.8" Then
Set r = Workbooks("Budget_CM11.xlsm").Worksheets("Recap").Range("AQ12:AY17")
r.Copy
'==> I see it opens the DataChart of the Chart for editing
PPShape.OLEFormat.DoVerb 2
'code needed here that should copy the Excel range
'within the PowerPoint Object (Chart?) Data
End If
End Sub
당신이 [연결 대상]로 차트를 붙여 넣을 수 없습니다 (https://www.google.co.uk/search?q=embedding+excel+chart+ into + powerpoint & oq = Embedding + excel + chart + & aqs = chrome.1.69i57j0l4.6352j1j4 & sourceid = chrome & ie = UTF-8) 자동 업데이트됩니까? – QHarr
@QHarr 현재 문제는 해결 될 것이라고 생각하지만 PowerPoint 프레젠테이션을 수정하지 말고 강제로 업데이트해야합니다. – CCM
@QHarr 잘 모르겠습니다. Excel (더 많은 볼륨)과 PowerPoint (여기에서 더 어려움)에서 데이터를 업데이트해야하므로 Excel VBA를 통해 작업하고있는 프로젝트를 수행하고 싶습니다. – CCM