2016-05-16 66 views
0

我已经写了一个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 

回答

0

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

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

寻址时通过你需要做的项目的.HasTextFrame检查,否则会出错e.g时的SmartArt包括行项目组的SmartArt。