VBA-如何确定显示的传奇条目数量

发布于 2025-01-18 22:04:43 字数 546 浏览 2 评论 0原文

我全心全意地寻找答案,我完全被困了。任何帮助将不胜感激!

看看这个示例:

如您所见,.chart中有20个。 >。 我想使用vba调整.legend大小和/或减少.legend字体大小,直到所有20 .series显示在.legend

但是我不知道如何确定.legendentries .legend中显示的

.legend.legendentries.count因此,我给了我“ 20”。

我很茫然。

I've looked all over for the answer to this and I am completely stumped. Any help would be greatly appreciated!

Look at this example:
example picture

As you can see, there are 20 .Series in the .Chart, but only 15 are visible in the .Legend.
I want to use VBA to adjust the .Legend size and/or reduce the .Legend font size until all 20 .Series are shown in the .Legend.

But I have no idea how to determine the number of .LegendEntries shown in the .Legend.

.Legend.LegendEntries.Count gives me "20" as a result.

I'm at a loss.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独行侠 2025-01-25 22:04:43

在您的示例中使用此代码(结果可能会有所不同),您可以确定哪些传奇条目不可见。它计算传奇窗口和传奇条目的顶部之间的差异。负数应表明它不可见

        Dim c As Chart, nLegH As Single
        Set c = ActiveChart
        With c.Legend
                nLegH = .Top + .Height
                Debug.Print nLegH
                For x = 1 To 20
                        Debug.Print .LegendEntries(x).Top, nLegH - .LegendEntries(x).Top
                Next x
        End With

Using this code on your example (your results may vary) you can identify which legend entries are not visible. It calculates the difference between the legend's window and the legend entry's top. A negative should indicate it is not visible

        Dim c As Chart, nLegH As Single
        Set c = ActiveChart
        With c.Legend
                nLegH = .Top + .Height
                Debug.Print nLegH
                For x = 1 To 20
                        Debug.Print .LegendEntries(x).Top, nLegH - .LegendEntries(x).Top
                Next x
        End With
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文