MS Graph SeriesCollection值 [英] MS Graph SeriesCollection Values

查看:49
本文介绍了MS Graph SeriesCollection值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有


我正在努力学习图表,在那里我尝试阅读系列中的值。谁能告诉我为什么这不起作用?


    

  s = Me.SPIGraph.SeriesCollection(1).Values



  s = Me.SPIGraph.Object.Application.Chart.SeriesCollection(1).Values


似乎Excel和Access的对象处理存在差异。我尝试了不同的变量声明 - 没有运气



我试图采用以下方式在Access 2010 x32 VBA下运行 - 没有运气。

   Dim   cht  作为 图表   s  作为 系列   p   As   Point 
Dim vals x As 整数

设置 cht = ActiveSheet < span class ="pun">。 ChartObjects 1 )。 Chart
设置 s = cht SeriesCollection 1

vals
= s

对于 x = LBound vals UBound vals
如果 vals x < span class ="pun">> 10 然后
s 积分 x
< span class ="pln"> MarkerBackgroundColor = RGB 255 0 0
MarkerForegroundColor = RGB 255 0 0
结束
结束 如果
下一步 x


有什么想法?


Greg

解决方案

嗨SysGreg,


访问中的图表是Graph.Chart对象,它与Excel中的图表不同。此图表没有Values属性。我没有找到任何可以在访问中返回图表值的属性。我能做的唯一解决方法是使用Point.DataLable
的文本作为值。


以下是示例。

 Private Sub Command0_Click()

Dim cht As Graph.Chart

Dim s As Graph.Series

Dim p As Graph.Point

Set cht = Me.Graph4.Object

Set s = cht.SeriesCollection(1)

每个p在s.Points

'确保该点有datalabel

p.HasDataLabel = True

pval = p .DataLabel.Text

MsgBox pval

'你也可以在获得价值后隐藏数据标签

p.HasDataLabel = False

下一个p

结束子

最好的问候,


Terry


Dear All

I'm struggling with a graph, where i try to read the values in the series. Can anybody tell me why is this not working?

    
 s = Me.SPIGraph.SeriesCollection(1).Values

neither

 s = Me.SPIGraph.Object.Application.Chart.SeriesCollection(1).Values

Seems there is a difference in object handling for Excel and Access. I tried different variable declarations - no luck

I tried to adopt following to run under Access 2010 x32 VBA - no luck.

Dim cht As Chart, s As Series, p As Point
Dim vals, x As Integer

    Set cht = ActiveSheet.ChartObjects(1).Chart
    Set s = cht.SeriesCollection(1)

    vals = s.Values

    For x = LBound(vals) To UBound(vals)
      If vals(x) > 10 Then
        With s.Points(x)
            .MarkerBackgroundColor = RGB(255, 0, 0)
            .MarkerForegroundColor = RGB(255, 0, 0)
        End With
      End If
    Next x

Any thoughts?

Greg

解决方案

Hi SysGreg,

Chart in access is a Graph.Chart object which is different from chart in Excel. This chart does not have Values property. I did not find any property which could return value of the chart in access. The only workaround I could do is using the text of Point.DataLable as the value.

Here is the example.

Private Sub Command0_Click()

Dim cht As Graph.Chart

Dim s As Graph.Series

Dim p As Graph.Point

Set cht = Me.Graph4.Object

Set s = cht.SeriesCollection(1)

For Each p In s.Points

'make sure the point has datalabel

p.HasDataLabel = True

pval = p.DataLabel.Text

MsgBox pval

'you could also hide the datalabel after getting the value

p.HasDataLabel = False

Next p

End Sub

Best Regards,

Terry


这篇关于MS Graph SeriesCollection值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆