admin管理员组文章数量:1287491
Please run the following code for testing needs.
Public Sub Macro1()
'Delete all charts
For i = ActiveSheet.Shapes.Count To 1 Step -1
If ActiveSheet.Shapes(i).Type = msoChart Then
ActiveSheet.Shapes(i).Delete
End If
Next i
'Add a chart.
With ActiveSheet.ChartObjects.Add(Left:=10, Top:=10, Width:=400, Height:=200)
.Name = "myChart"
End With
'Add a serie.
With ActiveSheet.ChartObjects("myChart").Chart.SeriesCollection.NewSeries
.ChartType = xlLine
.XValues = Array(10, 20, 30, 40, 50)
.Values = Array(1, 2, 3, 4, 5)
End With
'Apply a new chart style template
ActiveSheet.ChartObjects("myChart").Chart.ClearToMatchStyle
ActiveSheet.ChartObjects("myChart").Chart.ChartStyle = 233
End Sub
I want to extract all properties of above chart.
The following link provides a good answer but I dont know how to use VBE Locals window.
How to list properties of a chart object in VBA?
Please run the following code for testing needs.
Public Sub Macro1()
'Delete all charts
For i = ActiveSheet.Shapes.Count To 1 Step -1
If ActiveSheet.Shapes(i).Type = msoChart Then
ActiveSheet.Shapes(i).Delete
End If
Next i
'Add a chart.
With ActiveSheet.ChartObjects.Add(Left:=10, Top:=10, Width:=400, Height:=200)
.Name = "myChart"
End With
'Add a serie.
With ActiveSheet.ChartObjects("myChart").Chart.SeriesCollection.NewSeries
.ChartType = xlLine
.XValues = Array(10, 20, 30, 40, 50)
.Values = Array(1, 2, 3, 4, 5)
End With
'Apply a new chart style template
ActiveSheet.ChartObjects("myChart").Chart.ClearToMatchStyle
ActiveSheet.ChartObjects("myChart").Chart.ChartStyle = 233
End Sub
I want to extract all properties of above chart.
The following link provides a good answer but I dont know how to use VBE Locals window.
How to list properties of a chart object in VBA?
Share Improve this question edited Feb 24 at 15:51 Kram Kramer asked Feb 24 at 15:03 Kram KramerKram Kramer 1131 silver badge6 bronze badges 5 |2 Answers
Reset to default 2To display something in the locals window, you need to have a local variable pointing to whatever you are interested in.
Use a code like this (maybe you have to adapt it slightly)
Sub showChartInfo()
Dim ws As Worksheet, co As ChartObject, ch As Chart
Set ws = ThisWorkbook.Sheets(1)
Set co = ws.ChartObjects(1)
Set ch = co.Chart
End Sub
Set a breakpoint on the End Sub
-line and let the code run.
The tlbinf32.dll allows listing all properties of an object, but as its name says it only works in 32 bit office (I think). See: https://jkp-ads/articles/objectlister.aspx
本文标签: vbaHow to extract all properties of an excel chartStack Overflow
版权声明:本文标题:vba - How to extract all properties of an excel chart? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741258547a2367161.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
Dim ws: Set ws = ActiveSheet
beforeEnd Sub
, add a breakpoint onEnd Sub
then run. Expandws->shapes->item1->chart
– CDP1802 Commented Feb 24 at 15:20@
before their name. You also get an intellisense type drop-down. – Darren Bartrup-Cook Commented Feb 24 at 15:29