OLEFormat(未知成员):PowerPoint 中的无效请求

发布于 2024-12-29 02:15:43 字数 509 浏览 1 评论 0原文

我正在使用 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(未知成员):无效请求。我知道这对某人有用,但显然我插入的不是一个对象。为什么我会收到此错误?

I am using this particular code by 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  

I've embedded a line chart (with the ability to change values in excel) using insert menu in PowerPoint 2010. I'm getting an error that says OLEFormat (unknown member): Invalid Request. I know this has worked for someone out there but apparently what I've inserted is not an object. Why am I getting this error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜光 2025-01-05 02:15:43

访问底层 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

Accessing the underlying Excel worksheet is a little tricky - try this approach instead

  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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文