qprsoft
asked on
Visio swimlane resize
Hello
I am creating Visio objects in C#.
Height change goes fine, but same for width fails! (it actually does nothing)
What might be the reason?
Digging into VBA script, which is created if I record the actions, does not help. Actually, I have a guess that I should select some proper object, but I have not found one. I mean that this swimlane is created within some container which prevent from such resizing, but no solution yet!
I am creating Visio objects in C#.
Visio.Application visioApplication = new Visio.Application();
Visio.Document visioDocument = visioApplication.Documents.Add(@"C:/1.vsd");
Visio.Page currentPage = visioDocument.Pages[1];
Visio.Document currentStencil = visioApplication.Documents.OpenEx("XFUNC_M.vss", (short) Visio.VisOpenSaveArgs.visOpenDocked);
Visio.Shape swimlane = currentPage.Drop(currentStencil.Masters["Swimlane"], 0, 0);
//Height change goes fine
swimlane.Resize(VisResizeDirection.visResizeDirS, 10000, VisUnitCodes.visMillimeters);
//but same for width fails! (it actually does nothing)
swimlane.Resize(VisResizeDirection.visResizeDirE, 10000, VisUnitCodes.visMillimeters);
Height change goes fine, but same for width fails! (it actually does nothing)
What might be the reason?
Digging into VBA script, which is created if I record the actions, does not help. Actually, I have a guess that I should select some proper object, but I have not found one. I mean that this swimlane is created within some container which prevent from such resizing, but no solution yet!
ASKER
Thank you.
Yes I am using Visio 2010. Of course, it would be nice to have a generic solution.
I have found some sort for solution, but I am not sure if it has some side-effects.
Yes I am using Visio 2010. Of course, it would be nice to have a generic solution.
I have found some sort for solution, but I am not sure if it has some side-effects.
for (var i = 1; i <= currentPage.Shapes.Count; i++)
{
if (currentPage.Shapes[i].Name == "Separator")
{
currentPage.Shapes[i].Resize(VisResizeDirection.visResizeDirW, 100, isUnitCodes.visMillimeters);
break;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
I found the name of the parent shape by tracing backwards from the swimlane shape. If you look at the Width field in the shapesheet for the swimlane, you'll see that it derives its width from a user field in Sheet.5. The user field in Sheet.5 derives its value from the width of a shape called "Horizontal holder". Therefore, you need to change the width of the Horizontal holder.
I don't know the syntax in C# but in VBA you can do something like this:
Open in new window
BTW, you didn't mention which version of Visio you're using. My answer applies to Visio 2007 and prior. The structure of swimlanes is totally different in Visio 2010, so if you're using 2010, let me know.