我希望图表中的绘图线可以是基于用户指定的特定条件的实线,圆点或方点。我可以使用宏成功设置绘图的线条颜色和标记样式,但我似乎无法找到保存绘图线样式属性值的对象。我已尝试使用记录宏功能,但更改属性窗口中的线条样式不会显示在代码中,并且运行录制的宏无效。
非常感谢任何帮助!
答案 0 :(得分:3)
创建一个包含255个数据系列的图表,运行代码(并根据需要进行其他格式设置)。然后将其另存为模板。
Sub dd()
Dim wb As Workbook
Set wb = Application.ActiveWorkbook
Dim myChart As Chart
Set myChart = wb.Charts("Chart5")
Dim mySeries As series
For Each mySeries In myChart.SeriesCollection
mySeries.Format.Line.Weight = 1#
Next
End Sub
答案 1 :(得分:2)
YourChartSeries.Border.LineStyle = [some value from the XlLineStyle enumeration]
更新:在EXCEL 2010中录制我得到了这个 -
ActiveChart.SeriesCollection(1).Select
With Selection.Format.Line
.Visible = msoTrue
.DashStyle = msoLineSysDot
End With
ActiveChart.SeriesCollection(2).Select
With Selection.Format.Line
.Visible = msoTrue
.DashStyle = msoLineSysDash
End With
这可能是您正在寻找的。 p>
答案 2 :(得分:0)
如果你有折线图,我最终创建了一个switch语句,因为我无法弄清楚如何创建一个“Name”变量数组。见list of line types here
For j = i To num_lines_to_plot
count = count + 1
ActiveChart.SeriesCollection.NewSeries
With ActiveChart.SeriesCollection(j)
.Name = _
"='"**... (you'll need to fill this in)**
'create gradient
.Format.Line.ForeColor.RGB = RGB(255, 20 * count, 0)
'modify linetype
If count > 4 Then
line_type = count Mod 4
Else
line_type = count
End If
Select Case line_type
Case Is = 1
.Format.Line.DashStyle = msoLineSolid
Case Is = 2
.Format.Line.DashStyle = msoLineSquareDot
Case Is = 3
.Format.Line.DashStyle = msoLineDash
Case Is = 4
.Format.Line.DashStyle = msoLineLongDash
End Select
End With
Next