How can I set the picture associated with a node in a SmartArt graphic?

时光总嘲笑我的痴心妄想 提交于 2019-12-08 07:24:45

问题


SmartArt graphics can have pictures associated with the "nodes" (although this is only used by certain SmartArt templates). I know how to set the text of a node via VBA/VSTO automation, but I can't figure out how to set the picture.

Can it be done?


回答1:


Try something like this - if you've done any work in VBA with smartart this should make sense.

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

hope that makes sense!



来源:https://stackoverflow.com/questions/16157999/how-can-i-set-the-picture-associated-with-a-node-in-a-smartart-graphic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!