如何在SmartArt图形中设置与节点关联的图片?

时间:2013-04-22 22:45:01

标签: vba vsto ms-office office-2010

SmartArt图形可以包含与“节点”关联的图片(尽管这仅适用于某些SmartArt模板)。我知道如何通过VBA / VSTO自动化设置节点的文本,但我无法弄清楚如何设置图片。

可以吗?

1 个答案:

答案 0 :(得分:2)

尝试这样的事情 - 如果你在使用smartart的VBA中做过任何工作,这应该是有意义的。

Dim oSALayout As SmartArtLayout
Dim QNode As SmartArtNode
Dim oShp As Shape

Set oSALayout = Application.SmartArtLayouts(91) 'reference to organization chart
Set oShp = Chart.Shapes.AddSmartArt(oSALayout, ileft, 2, iWidth, iHeight)    
Set QNode = oShp.SmartArt.AllNodes.Add

...

' note that there may be more than one shape associated with each node, I found that those org chart/smart art layouts with a specific "picture box" typically use Shapes.Item(2) 

With QNode.Shapes.Item(1).Fill
    .Visible = msoTrue
    .UserPicture "c:\somepath\picture.jpg"
    .TextureTile = msoFalse
End With

希望有意义!