有没有办法根据用户在 C# Windows 窗体应用程序中创建的 TreeView 在 Word 中创建 SmartArt 层次结构图表?
感谢您的帮助。
最佳答案
像这样尝试:
private void button2_Click(object sender, EventArgs e)
{
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add();
// here try from 1 to 15 until you find the layout you are interested in...
var myLayout = oDoc.Application.SmartArtLayouts[8];
var smartArtShape = oDoc.Shapes.AddSmartArt(myLayout, 50, 50, 200, 200);
smartArtShape.AlternativeText = "xxxx";
}
这将配置为使用 layout
nr 8 的 SmartArt
Shape 放入文档中。它没有很好的记录,我花了很多时间来寻找正确的文章和示例:
了解您不能使用 new
关键字创建 SmartArtLayout
对象,但应使用应用程序布局集合提供的任何对象,这一点非常重要...
Application.SmartArtLayouts Property (Word)
这是一些背景... Creating Custom SmartArt Layouts with Office Open XML for Office 2007 and Office 2010
祝你好运:)
关于c# - 在 C# 中从 TreeView 创建 SmartArt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9268630/