本文介绍了OLEFormat(未知成员):PowerPoint中的无效请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Sub a()

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

设置oSl = ActivePresentation.Slides(1)

设置oSh = oSl.Shapes(1)

with oSh.OLEFormat.Object.WorkSheets(1)
.Range(A1)。Value = .Range(A1)。Value + 1
.Range( A2)Value = .Range(A2)。值 - 1
结束

设置oSl =没有
设置oSh =没有

End Sub

我已经嵌入了一个折线图(有能力更改excel中的值),使用在PowerPoint 2010中插入菜单。我收到一条错误,表示OLEFormat(未知成员):无效的请求。我知道这是为某人在那里工作,但显然我插入的不是一个对象。为什么我得到这个错误?

解决方案

访问底层的Excel工作表有点棘手 - 尝试使用这种方法

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

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

myChartData.Activate

设置myWorkBook = myChartData.Workbook
设置myWorkSheet = myWorkBook.Worksheets(1)

使用myWorkSheet
.Range(A1)。Value = .Range(A1 ).Value + 1
.Range(A2)。Value = .Range(A2)。值 - 1
结束
myWorkBook.Close
设置myWorkBook =没有
End Sub


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?

解决方案

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

这篇关于OLEFormat(未知成员):PowerPoint中的无效请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 12:00