gpt4 book ai didi

excel - OLEFormat(未知成员): Invalid Request in PowerPoint

转载 作者:行者123 更新时间:2023-12-04 20:47:36 26 4
gpt4 key购买 nike

我正在使用 Belisarius 的这个特殊代码:

Sub a()

Dim oSl As PowerPoint.Slide
Dim oSh As PowerPoint.Shape

Set oSl = ActivePresentation.Slides(1)

Set oSh = oSl.Shapes(1)

With oSh.OLEFormat.Object.WorkSheets(1)
.Range("A1").Value = .Range("A1").Value + 1
.Range("A2").Value = .Range("A2").Value - 1
End With

Set oSl = Nothing
Set oSh = Nothing

End Sub

我使用 PowerPoint 2010 中的插入菜单嵌入了一个折线图(能够更改 excel 中的值)。我收到一条错误消息,显示 OLEFormat (unknown member): Invalid Request。我知道这对那里的某个人有用,但显然我插入的不是对象。为什么我会收到此错误?

最佳答案

访问底层 Excel 工作表有点棘手 - 请尝试使用此方法

  Sub Test()
Dim myChart As Chart
Dim myChartData As ChartData
Dim myWorkBook As Object
Dim myWorkSheet As Object

Set myChart = ActivePresentation.Slides(1).Shapes(1).Chart
Set myChartData = myChart.ChartData

myChartData.Activate

Set myWorkBook = myChartData.Workbook
Set myWorkSheet = myWorkBook.Worksheets(1)

With myWorkSheet
.Range("A1").Value = .Range("A1").Value + 1
.Range("A2").Value = .Range("A2").Value - 1
End With
myWorkBook.Close
Set myWorkBook = Nothing
End Sub

关于excel - OLEFormat(未知成员): Invalid Request in PowerPoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8978867/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com