【问题标题】:Why Chart ApplyDataLabels doesn't work at Access 2010为什么 Chart ApplyDataLabels 在 Access 2010 中不起作用
【发布时间】:2014-12-15 03:41:15
【问题描述】:

我正在 Access 2010 中构建一些图表并尝试将它们自动化。 但我无法通过 vba 应用数据标签。

当我尝试使用 ApplyDataLabels 时,我收到错误 438:

Dim mychart As Object
Dim myseries As Object
Dim ax As Object
Dim pt As Object

Set mychart = frm.ChartSpace.Charts(0)

For Each myseries In mychart.SeriesCollection
    myseries.ApplyDataLabels '438 - Object doesn't support this property or method
Next

我需要做什么才能使 datalabel 可用?

提前致谢!

法比奥。

【问题讨论】:

    标签: vba ms-access charts label series


    【解决方案1】:

    我找到了解决办法:

    Dim dl as Object
    For Each myseries In mychart.SeriesCollection
            Set dl = myseries.DataLabelsCollection.Add
            dl.NumberFormat = "0.00"
    Next
    

    【讨论】:

      【解决方案2】:

      此过程根据使用 bShow 参数传递的数据显示/隐藏值。图形对象是从一个表单对象 (oFrmGrafico) 设置的,该对象具有名为 Grafico (oFrmGrafico!Grafico.Object) 的 Graph 类型控件。

      util_Log_MsgBoxErr 是一个内部过程。你可以通过MsgBox Err.Number & ": " & Err.Description, vbExclamation更改它

      mbExisteGrafico 是一个全局范围的布尔变量,用于收集图是否存在。

      Public Sub MostrarValores(ByVal bMostrar As Boolean)
      On Error GoTo MostrarValores_Err
      
          Dim objGraph As Object  'Chart
          Dim srs As Object       'Series
          Dim pt As Object        'Point
          
          If mbExisteGrafico Then
              Set objGraph = oFrmGrafico!Grafico.Object
              With objGraph
                  .ApplyDataLabels
                  For Each srs In .SeriesCollection
                      For Each pt In srs.Points
                          pt.DataLabel.ShowValue = bMostrar
                      Next
                  Next
              End With
          End If
      
      MostrarValores_Sal:
      On Error Resume Next
          Set pt = Nothing
          Set srs = Nothing
          Set objGraph = Nothing
          Exit Sub
      MostrarValores_Err:
          util_Log_MsgBoxErr Err.Number, Err.Description, "Class|Sub: cGraficos", "MostrarValores"
          Resume MostrarValores_Sal
      End Sub
      

      【讨论】:

        猜你喜欢
        • 2016-02-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-16
        • 1970-01-01
        • 2020-03-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多