[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Visio swimlane resize

Posted on 2011-05-04
5
Medium Priority
?
4,230 Views
Last Modified: 2012-05-11
Hello

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);

Open in new window


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!
0
Comment
Question by:qprsoft
  • 2
4 Comments
 
LVL 31

Expert Comment

by:Scott Helmers
ID: 35700119
Your assumption about what's wrong is very close. The swimlane derives it's width from a "parent" shape created for you by the swimlane add-in code. Consequently, you can't set the width of an individual swimlane directly. Instead, you need to change the width of the parent shape.

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:
Dim shp As Shape

Set shp = ActivePage.Shapes("Horizontal holder")
shp.Cells("Width").Formula = 13

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.
0
 

Author Comment

by:qprsoft
ID: 35718891
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.

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;
}
}

Open in new window


0
 
LVL 31

Accepted Solution

by:
Scott Helmers earned 2000 total points
ID: 35734440
This is interesting... I've played a lot with Visio 2010 containers, of which swimlanes are an example. However, the cross-function flowchart (CFF) add-in software that comes with Visio is overriding some of the standard container behavior, including some of the size adjustments.

Good find in your post above -- the Separator is a special shape at the right edge of a swimlane container that creates a "phase". I'm sure you've seen the word "Phase" in the upper right corner. Though the CFF code prevents you from changing the lane width directly, you can drag the phase separator via the UI to adjust the lane width. And as you've discovered, you can also move it via code.

If you haven't tried it yet, drag another Separator from the stencil onto the swimlane, and then drag it to change the new phase boundary you've created. My point is that your code will need to be aware that there could be more than one separator in the CFF structure. The first should be called "Separator" and subsequent ones should be "Separator.nn".
0
 
LVL 19

Expert Comment

by:Amandeep Singh Bhullar
ID: 37505706
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question