【问题标题】:Smart Art Arrays智能艺术阵列
【发布时间】:2016-09-12 14:39:33
【问题描述】:

我编写了一个 for 循环来检查幻灯片上智能艺术中使用的每个字体大小,并输出形状中每个文本块的字体大小。由于某种原因,数组中的第一个条目正确更新(例如,我将一个文本块作为与字体大小连接的字符串)但数组中的任何后续条目仅更新字体大小,但不获取实际块的文本。数组被正确计数(例如 5 个智能艺术形状被正确计数)。

Dim j,e,f as integer
Dim osh as shape
Dim osl as slide

Dim smrtCount as integer
Dim osmrtSize()
dim osmrtSizeMatch()

set osl = activewindow.view.slide

For each
With osh in osl.shapes
If .Type = msoSmartArt Then
            smrtCount = smrtCount + .GroupItems.Count
            ReDim Preserve osmrtSizeMatch(1 To smrtCount)
            ReDim Preserve osmrtSize(1 To smrtCount)
            For j = 1 To .GroupItems.Count
                e = e + 1
                f = f + 1
                osmrtSize(e) = .GroupItems(j).TextFrame.TextRange.Runs(j).Font.Size 'store the sizes
                osmrtSizeMatch(f) = .GroupItems(j).TextFrame.TextRange.Runs(j).Text '& " = " & .GroupItems(j).TextFrame.TextRange.Runs(j).Font.Size '& vbCrLf
            Next j
End If

【问题讨论】:

    标签: arrays vba powerpoint


    【解决方案1】:

    想通了。需要使用 .smartart.allnodes() 而不是 .groupitems:

    osmrtSizeMatch(f) = .SmartArt.AllNodes(j).TextFrame2.TextRange.Text
    

    【讨论】:

      【解决方案2】:

      当通过组项目处理 SmartArt 时,您需要对项目进行 .HasTextFrame 检查,否则可能会出错,例如当 SmartArt 包含一行时。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多