0
我想更新一些我的幻灯片使用Excel中的数据,并使用下面的代码粘贴到PowerPoint图表后端。移调粘贴复制范围从Excel到PowerPoint图表
Sub updateSlides()
Application.DisplayAlerts = False
Dim xlApp, xlWorkBook, xlSheet As Object
Set xlApp = CreateObject("Excel.Application")
' Not transposing
xlApp.DisplayAlerts = Flase
xlApp.Visible = True
Set xlWorkBook = xlApp.Workbooks.Open("ExcelFilePath")
Set xlSheet = xlWorkBook.Sheets("SheetName")
For i = 1 To 9
With ActivePresentation.Slides(i)
Set charts = .Shapes("Chart 37").Chart.ChartData
charts.Activate
Set chartData = charts.Workbook.Sheets("Sheet1")
xlSheet.Range(xlSheet.Cells(2 + i, 2), xlSheet.Cells(2 + i, 3)).copy
chartData.Range("B8").PasteSpecial Paste:=-4163
' I need to transpose the copied data here'
charts.Workbook.Close
End With
If i < 9 Then
ActiveWindow.View.GotoSlide Index:=ActiveWindow.Selection.SlideRange.Duplicate.SlideIndex
End If
Next i
xlApp.Quit
xlApp.DisplayAlerts = True
Set xlApp = Nothing
' ActivePresentation.Save
Application.DisplayAlerts = True
End Sub
在第20行,我需要转置复制的数据并粘贴到提供的目标范围。 任何帮助,非常感激。
谢谢。 codw作品。 –