相关疑难解决方法(0)

将形状添加到新的Visio文档

我有这个代码创建一个新的Visio文档并添加一个矩形.它有效,但我不想打开另一个文档来获取Masters集合.问题是新文档有一个空的Masters形状集合.我在Document类中找不到一个方法来向Masters集合添加形状,并且我可以找到添加形状的所有示例,假设您有一个现有文档.有没有更好的方法来做我想要的?

// create the new application
Visio.Application va = new Microsoft.Office.Interop.Visio.Application();

        // add a document
        va.Documents.Add(@"");

       // Visio.Documents vdocs = va.Documents;

        // we need this document to get its Masters shapes collection
        // since our new document has none 
        Visio.Document vu = vdocs.OpenEx(@"C:\Program Files (x86)\Microsoft       Office\Office12\1033\Basic_U.vss", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked);

        // set the working  document to our new document
        Visio.Document vd = va.ActiveDocument;

        // set the working page to the active page
        Microsoft.Office.Interop.Visio.Page vp = va.ActivePage;

      // if we try this from the …
Run Code Online (Sandbox Code Playgroud)

c# visio office-interop

4
推荐指数
1
解决办法
6216
查看次数

标签 统计

c# ×1

office-interop ×1

visio ×1