Category Archives: Uncategorized

Polar Array – Part 2

It has been almost two years since I blogged, so it is time to dust off the blog.

Today in the newsgroups someone asked about using the Polar Array VBA sample from the Visio MVP website, but rather than place a specific shapes multiple times, arrange the shapes that are selected.

As usual, the original credit goes to Chris

Sub PolarArray()
‘ by Chris Roth
Dim shp As Visio.Shape, shpObj As Visio.Shape, celObj As Visio.Cell
Dim iNum As Integer, i As Integer
Dim dRad As Double, dAngStart As Double, dAng As Double
Dim x As Double, y As Double
Dim VsoSelect As Visio.Selection
Dim VsoShape As Visio.Shape

‘ obtain the shape to be distributed
Set shp = Visio.ActiveWindow.Selection(1)

Const PI = 3.14159265358

Set VsoSelect = Visio.ActiveWindow.Selection

If VsoSelect.Count > 1 Then
    iNum = VsoSelect.Count
    dRad = InputBox(“Enter the radius for the polar array in inches:”, “Polar Array”)
    dAngStart = InputBox(“Enter the first angle in degrees (0 deg = 3 o’clock):”, “Polar Array”)
    dAngStart = dAngStart * PI / 180 ‘Convert to radians
    dAng = 2 * PI / iNum
    For i = 1 To iNum
    x = dRad * Cos(dAngStart + dAng * (i – 1)) + 4.25
    y = dRad * Sin(dAngStart + dAng * (i – 1)) + 5.5
    Set VsoShape = VsoSelect(i)
‘    Set shpObj = Visio.ActivePage.Drop(shp, x, y)
    VsoShape.Cells(“Pinx”).Formula = x
    VsoShape.Cells(“piny”).Formula = y
    ‘ rotate the shape – This only makes sense if this is a group of chairs around a table
‘    Set celObj = VsoShape.Cells(“Angle”)
‘    celObj.Formula = Str(Int((i – 1) * 360 / iNum)) + “deg.”
    Next i
Else   ‘ if only one shape is selected, then
    iNum = InputBox(“Enter the number of items in the array:”, “Polar Array”)
    dRad = InputBox(“Enter the radius for the polar array in inches:”, “Polar Array”)
    dAngStart = InputBox(“Enter the first angle in degrees (0 deg = 3 o’clock):”, “Polar Array”)
    dAngStart = dAngStart * PI / 180 ‘Convert to radians
    dAng = 2 * PI / iNum
    For i = 1 To iNum
    x = dRad * Cos(dAngStart + dAng * (i – 1)) + 4.25
    y = dRad * Sin(dAngStart + dAng * (i – 1)) + 5.5
    Set shpObj = Visio.ActivePage.Drop(shp, x, y)
    shpObj.Text = i
    ‘ rotate the shape
    Set celObj = shpObj.Cells(“Angle”)
    celObj.Formula = Str(Int((i – 1) * 360 / iNum)) + “deg.”
    Next i
End If
End Sub

Creating Automation Friendly Visio diagrams

About a week ago I was asked if it was possible to save the information from a hand drawing Orgchart (one done without the wizard). The simple answer was yes, but with a few caveats. It would not be an easy task to extract all the information from the diagram.

Visio allows the user two views of their diagram; the one most people are familiar with is the one that appears on the screen or the printed page; the second is what a program can “see” of the drawing through automation. What may appear logical in the diagram, may not actually be the true representation. For example, the ethernet shape in the network stencil has only eight connection points. By dropping a second ethernet shape on top of the first, it appears that there is a single ethernet shape with sixteen connection points. From the automation side, there would still be two seperate ethernet shapes.

So here are some guidelines for creating Visio diagrams, not necessarily orgcharts, so that they are more automation friendly.

The first suggestion is to standardize on the shapes. It is a lot easier for an automation routine to understand a drawing if all similar shapes have the same master. For example, most diagrams contain extra shapes in addition to the ones used for the connected diagram. There may be legends, title blocks, side comments and company identifiers. Thses shapes can be identified by the fact that they are unconnected, but it would be easier if the automation routine was looking for specific shapes.

Background pages would reduce the number of unconnected shapes on the foreground pages. It would add consistency to the drawings by making sure that common information appears in the same location on each page.

If you are creating your own shapes, keep them as simple as possible. Do not avoid grouped shapes, but make sure they are necessary. Each group shape is a collection of shapes and once one is found, this new collection of shapes has to be processed. Most shape features (connection points, custom properties and various geometry sections) can be contained in a single shape. The only real need for grouping shapes is to add secondary colours, line formats or text blocks.

One of the caveats on the drawing I saw was how was it possible to extract the name and position as seperate items from the OrgChart. Luckily in the example, though the two pieces of information are in the same text block, each had a different format (One was in bold). Using the Characters collection in Visio makes it possible to seperate the two strings. If starting from scratch, it would have been easier to use custom properties and reference the custom properties from the text block.

When connecting shapes, make sure the connection goes to the connection point on the logical shape. I have seen some shapes that appear to connected, but in fact, the free end of it’s connecting line is just sitting near one of the other lines. In another example, a group of vertically stacked individuals appear to be connected to a supervisor, but in fact each shape is connected to the shape above it rather than to the logical shape, the supervisor.

Connecting lines are 1-d shapes and have a beginning and an end. Be consistent as to whether the supervisor is at the beginning or the end of the line. I’ll leave it to the academics as to which one it should be.

A Visio line pattern

During my usual weekend hunt for Visio items on the net I came across an article by Dan Brown on how to create a simple custom line pattern that indicates direction. The line pattern tapers in the direction of travel. This is accomplished by choosing a behaviour that stretches rather than repeats the line pattern. Dan’s detailed directions are at:

John… Visio MVP

Only one background page?

In several online tutorials (non Microsoft), it is usually mentioned that you can only have one background page. This is partially true. A page can only have one background page. This is often interpreted as meaning only foreground pages, but background pages can also have background pages. So it is possible, that a foreground page can have a series of background pages attached to it. Why would you want to do it? The advantage of a background page is that you can place objects in consistent locations on all pages that print. (foreground pages print, background pages do not print.) So with multiple background pages, the one at the end of the chain could contain the title block and any artwork common to it. The next to last could contain common item specific to a subset of the pages and so on.

Three minor point on background pages.

  1. Not all background pages are labelled background. (Mark: how about different colours on the tabs?)

  2. They will appear to the right of the foreground pages.

  3. Though they can not be printed they will show up in print preview.

John… Visio MVP

Headers/Footers or Background Pages?

Anyone new to Visio may not be aware of why Visio has both Headers/Footers and background pages or know that there is such a thing as a background page.

In Visio 1, the developers created the concept of type basic types of pages; foreground and background. The foreground pages were the pages that were actually printed and the background pages contained information that was to appear in a fixed position on the foreground page. So the concept of Headers/Footers common in other product like Word and Excel was implemented by creating a background. Anything that can be placed on a foreground page can be placed on a background page including special fields that would inherit information from the foreground page it was attached to (i.e. page name or page number).

Visio 5 introduced the concept of Headers/Footers to address a specific printing problem. When a Visio drawing prints over several physical pages, there was a request to have the individual physical pages marked with a header/footer. Since this was addressing a specific problem, the amount and type of information in the header or footer was limited.

As long as the Visio page is the same size as the physical page, the background page can do everything the Header/Footer can do (and more). If the information in the header/footer is adequate, then they may be more convenient to use. It’s your choice.

John… Visio MVP

Document ShapeSheet: Where? What? Why?

Note: This post is a lot funnier if you try to read it out loud!

Document ShapeSheet

Visio solution developer’s will be excited to learn that Visio has a Document ShapeSheet. This ShapeSheet looks similar to a page’s ShapeSheet, which in turn is similar to any old shape’s ShapeSheet.

While said ShapeSheet has fewer sections than a stock shape’s, it does support the User-defined Cells section. This is a great place to store variables and values that apply to all shapes and pages in the document.

There are two ways to access the Document ShapeSheet. Guess which one isn’t documented:

  • Hold the Shift key, then click: Window > Show ShapeSheet
  • View the Drawing Explorer and right-click on the Drawing object at the top.

The syntax for referencing a variable in the Document ShapeSheet is as follows:

User.mvp = TheDoc!User.mvp

Seemingly simple, a Shift + Show ShapeSheet sleight-of-hand will have you setting your solutions ship-shape in seconds!

Chris Roth, Visio MVP


The purpose of this blog is to provide the community with information about Visio. We will try to provide both technical information as well as trivia.

Visio has been around for thirteen years and gone through almost as many versions. Five years ago it was aquired by Microsoft and is now member of Microsoft’s Office family. For more information on Visio’s history.

The Visio MVPs; Al Edlund, Senaj Lelic, John Marshall, David Parker, Chris Roth and Graham Wideman