Dear all
I am using Visual Studio 2017 community edition, and I need to create a workflow with C#.
My code looks like this:
application = new Microsoft.Office.Interop.Visio.Application();
//application.Visible = false;
application.Documents.Add("");
docs = application.Documents;
stencil = docs.OpenEx("BASFLO_U.VSTX", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked);
page = application.Application.ActivePage;
master = stencil.Masters.get_ItemU(@"Swimlane");
However, when I run the code at the last statement I get the message:
System.Runtime.InteropServices.COMException: 'Object name not found.'
Any ideas will be really appreciated.
A few problems with your code.
You have opened a new template and referred to it as a stencil. However, there is no Swimlane shape in the Basic Flowchart stencil.
You need to open the Cross-functional stencil.
The folloowing code is untried...
application = new Microsoft.Office.Interop.Visio.Application();
Document doc = application.Documents.Add("");
Document stencil = doc.OpenEx("XFUNC_U.VSSX", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked);
Page pagObj = application.Application.ActivePage;
Shape shpObj = pagObj.drop("Swimlane", x, y); // x, y are the coordinates to drop shape at
Hello
That is correct, that was the issue.
Thanks a lot