我正在尝试使用excel中的数据更新我的一些幻灯片,并使用以下代码将其粘贴到PowerPoint Chart后端。
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行,我需要转置复制的数据并将其粘贴到提供的目标范围内。 任何帮助都得到了适当的赞赏。
答案 0 :(得分:1)
尝试使用a[0] = 0x30, b: 0x30, 48, s: 0x30, 48
a[1] = 0x61, b: 0x61, 97, s: 0x61, 97
a[2] = 0xeb, b: 0xeb, 235, s: 0xffffffeb, -21
a[3] = 0x0, b: 0x0, 0, s: 0x0, 0
参数:
Transpose
同样纠正错字:
chartData.Range("B8").PasteSpecial Paste:=-4163, Transpose:=True