我正在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
我需要做些什么才能使数据标签可用?
提前致谢!
法比奥。
答案 0 :(得分:1)
我找到了解决方案:
Dim dl as Object
For Each myseries In mychart.SeriesCollection
Set dl = myseries.DataLabelsCollection.Add
dl.NumberFormat = "0.00"
Next
答案 1 :(得分:0)
此过程显示/隐藏基于使用 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