Auto-layout shapes using Automation from VBS

R

rodionos

Hello,

I am educating myself on automation capabilities available in Visio 2003. I
can now create a simple diagram with primitive shapes using VBS. Is it
possible to layout shapes on the page similar to Shape --> Lay out shapes,
only programmatically? This would relieve me from positioning each shape
manually.

Thank you!

Sergei
 
J

JuneTheSecond

You might record your operation for layout shapes into macro, for example,
Sub Macro1()
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Layout Shapes")
Application.ActiveWindow.Page.PageSheet.CellsSRC(visSectionObject,
visRowPageLayout, visPLOPlaceStyle).FormulaU = "1"
Application.ActiveWindow.Page.PageSheet.CellsSRC(visSectionObject,
visRowPageLayout, visPLORouteStyle).FormulaU = "5"
Application.ActiveWindow.Page.Layout
Application.EndUndoScope UndoScopeID1, True
End Sub
 
R

rodionos

Thanks! I keep forgetting about macros as one of the most simple ways to
learn Office internals.
 
J

John Marshall, MVP

One easy way to determine how to do something in code is to use the macro
recorder. Not all activities are recordable, but enough to get started.

The references to UndoScopeID1 in JuneTheSecond's code are not necessary and
can be removed.

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
Visio Wishlist http://www.mvps.org/visio/wish_list.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top