0

我有一个 Visio 文档和一个 Stencil(.vss) 文件。要求:在 Visio 文档中动态添加此模具文件。

    private static void InsertStencilsToVisio()
    {           
        string fileName = @"C:\Visio Files\TestVisio.vdw";
        if (System.IO.File.Exists(fileName))
        {
            visioDocument = visioApplication.Documents.Open(fileName);
            visioPage = visioApplication.Window.Application.ActivePage;
            eswStencilDocument = visioPage.Application.Documents["eswstencil.vss"];
            CreateShapes();
        }
    }

我可以使用 VisOpenSaveArgs 吗?破解这个。

4

2 回答 2

0

自己破解的。在此,我打开了 Visio 文档,并在打开时将模具动态停靠到 visio。稍后,文档会使用模板保存。

   private static void InsertStencilsToVisio()
   {   visioApplication = new Application();
        string fileName = @"C:\siva\CreateGen1Visio\pd-m-0001_1.11.vdw";
        string stencilFileName = @"C:\siva\CreateGen1Visio\eswstencil.vss";

        try
        {
            if (System.IO.File.Exists(fileName))
            {
                visioDocument = visioApplication.Documents.OpenEx(fileName, (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDontList);
                visioPage = visioDocument.Application.ActivePage;
                visioPage.Application.Documents.OpenEx(stencilFileName, (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked);
                visioDocument.SaveAsEx(fileName, (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visSaveAsWS);
            }
        }
   }
于 2013-05-29T07:39:19.870 回答
0

是的,您可以使用 visOpenRO + visOpenDocked:

visioDocument = visioApplication.Documents.Open(fileName);

visioApplication.Documents.OpenEx("eswstencil.vss", 
    (short)VisOpenSaveArgs.visOpenRO|(short)VisOpenSaveArgs.visOpenDocked);
于 2013-05-28T15:41:26.500 回答