Can anyone point me to an example of how to programatically create a statechart in visio? I can create blank pages, drop shapes, open template etc, but when I try to add transitions it complains that the page is not the right type.
Can't find a sample anywhere.
Alternatively: I can save the user actions to create the chart as a macro. Can I run that programatically?
Thanks.
< edit >
Step away from the PC for 2 minutes and you realise you should have put the code snippet in the question and not try to put it in comments. Forest: meet trees...
Visio.Document umlStencil = visioApp.Documents.OpenEx(@"UMLSTA_M.vss", (short)VisOpenSaveArgs.visOpenDocked);
Visio.Page page = visioDoc.Pages.Add();
Visio.Shape s1 = page.Drop(umlStencil[@"State"], 5.0, 5.0);
Visio.Shape s2 = page.Drop(umlStencil[@"State"], 5.0, 5.0);
Visio.Shape transition = page.Drop(umlStencil[@"Transition"], 1.0, 1.0);
As you can see, pretty similar to the snippet in the answer below.
< / edit >