Vba 向条形图中的系列添加边框

Vba 向条形图中的系列添加边框,vba,excel,excel-2016,Vba,Excel,Excel 2016,我正在使用宏将图表插入电子表格: Option Explicit Sub Macro1() Dim overskrifter As Range Dim i As Long Dim høgde As Long, breidde As Long Call fjernkurver i = 1 høgde = 240: breidde = 350 Set overskrifter = Oppsummering.Range("C5:L5")

我正在使用宏将图表插入电子表格:

Option Explicit

Sub Macro1()

    Dim overskrifter As Range
    Dim i As Long
    Dim høgde As Long, breidde As Long

    Call fjernkurver

    i = 1
    høgde = 240: breidde = 350
    Set overskrifter = Oppsummering.Range("C5:L5")

    With Kurver.Shapes.AddChart2(201, xlColumnClustered)
        .Name = "Graf_" & i
        With .Chart.SeriesCollection.NewSeries
            .XValues = overskrifter
            .Values = overskrifter.Offset(i, 0)
            .Name = Oppsummering.Range("B5").Offset(i, 0)
            ' "Olive"
            .Points(1).Format.Fill.ForeColor.RGB = RGB(128, 128, 0)
            ' "Dark khaki"
            .Points(8).Format.Fill.ForeColor.RGB = RGB(189, 183, 107)
            ' Green (Atlantis)
            .Points(9).Format.Fill.ForeColor.RGB = RGB(146, 208, 80)
            With .Format.Line
                .Visible = msoTrue
                .Weight = 0.5
                '.ForeColor.RGB = RGB(0, 0, 205)
                .ForeColor.RGB = RGB(255, 0, 0)
                .Transparency = 0
            End With
        End With
        .Height = høgde
        .Width = breidde
        .Top = 5 + ((i - 1) \ 3) * (5 + høgde)
        .Left = 5 + ((i - 1) Mod 3) * (5 + breidde)
        .Chart.HasTitle = True
        .Chart.ChartGroups(1).GapWidth = 150
        .Chart.ChartGroups(1).Overlap = 0
    End With
End Sub

Sub fjernkurver()
    Dim co As ChartObject

    For Each co In Kurver.ChartObjects
        co.Delete
    Next co
End Sub
在大多数情况下,它工作正常,但我对这部分代码有一些问题:

        With .Format.Line
            .Visible = msoTrue
            .Weight = 0.5
            '.ForeColor.RGB = RGB(0, 0, 205)
            .ForeColor.RGB = RGB(255, 0, 0)
            .Transparency = 0
        End With
它应该在图形中的所有条形周围添加边框,红色表示RGB(255,0,0),蓝色表示RGB(0,0255)

然而,据我所知,任何酒吧都没有添加任何边界。有人能指出我哪里出了问题吗

该图表最终如下所示:

序列的
.Format.Line
属性似乎适用于条形图边框以外的其他对象-猜测可能是连接线或散点图等数据点的线

为了实际勾勒出条形图,我替换了有问题的代码

With .Format.Line
    .Visible = msoTrue
    .Weight = 0.5
    .ForeColor.RGB = RGB(255, 0, 0)
    .Transparency = 0
End With


请不要问我为什么
.Format.Line.Weight
仍然适用于边框,至少我让它工作了。给写过文章的人的大道具。

我的解决方案有效吗?有点难跟上code@learnAsWeGo不
.Border.LineStyle = xlContinuous
.Border.Color = 9851952
.Format.Line.Weight = 0.5