Revision Dates per Page

One of the posters in the newsgroup was asking about providing a revision date on each page of a Visio document and this is what I came up with. The only dates that are associated with a Visio drawing are done at the document level, so another apporach is necessary.

To create a date stamp at the page level, add a custom property/Shape Data to the pagesheet for each page. This property can then be changed automatically when the page is altered. Since the property is updated automatically, the property will also be created if it does not exist.

Private Sub Document_BeforeSelectionDelete(ByVal Selection As IVSelection)
UpdateDateReviewed
End Sub

Private Sub Document_PageAdded(ByVal Page As IVPage)
UpdateDateReviewed
End Sub

Private Sub Document_ShapeAdded(ByVal Shape As IVShape)
UpdateDateReviewed
End Sub

Private Sub Document_ShapeExitedTextEdit(ByVal Shape As IVShape)
UpdateDateReviewed
End Sub

Sub UpdateDateReviewed()

Dim vsoShape As Visio.Shape
Dim intPropRow As Integer

Set vsoShape = ActivePage.PageSheet

If vsoShape.CellExists(“Prop.DateRevised”, False) = False Then
    intPropRow = vsoShape.AddRow(visSectionProp, visRowLast, visTagDefault)
    vsoShape.CellsSRC(visSectionProp, intPropRow, visCustPropsLabel).FormulaU = “””DateRevised”””
    vsoShape.CellsSRC(visSectionProp, intPropRow, visCustPropsValue).RowNameU = “DateRevised”
    vsoShape.CellsSRC(visSectionProp, intPropRow, visCustPropsType).FormulaU = “5”
    vsoShape.CellsSRC(visSectionProp, intPropRow, visCustPropsFormat).FormulaU = “”
    vsoShape.CellsSRC(visSectionProp, intPropRow, visCustPropsPrompt).FormulaU = “”
    vsoShape.CellsSRC(visSectionProp, intPropRow, visCustPropsValue).FormulaU = “”
   
End If

vsoShape.Cells(“Prop.DateRevised”) = Format(Now(), “00000.00000”)

End Sub

 

From Adobe Illustrator to Visio

One thing that got me hooked on Visio from the beginning was that you were not limited to the shapes that were supplied by the product, You could create shapes from scratch, modify existing shapes or wrap an image from any source into a Visio shape. So, I am always on the hunt for new shapes that are available on the internet.

Recently, I came across a set of well made shapes and was able to get in touch with the creator. Though the shapes looked good, they did not have any of the smarts that can be associated with Visio shapes. The Visio shapes were just foreign images that could not be changed or coloured. The shapes were originally created in Adobe Illustrator and imported into Visio. I tried using other export options from Illustrator, but none allowed me to ungroup the shapes in Visio so the shape can be disected into individual elements that be recombined.

Thanks to Enric Mañas, a PowerPoint MVP, I found out that it is possible to disect the shape by using PowerPoint. The file needs to be first saved as an EPS in Illustrator. The EPS file is then inserted into a new PowerPoint slide and then saved as a WMF file. The WMF file is then inserted in to a Visio drawing and this new shape can then be ungrouped.

So if you need to manipulate a shape created in Adobe Illustrator, use PowerPoint to convert an EPS file to a WMF file.

Multiple copies while Duplex printing

Visio has a problem with duplex printing.

If you ask for multiple copies while duplex printing, you only get one copy. This is rather annoying, but the problem is not with duplex printing. The issue is with the collate option. You can duplex print a Visio document and request mutiple copies and your document will print the correct number of pages, only if you do not select collate. Of course, the pile of paper generated is useless. What is printed on the front and back of the first piece of paper is two copies of page 1.

There is a knowledge based article http://support.microsoft.com/kb/924114 but that indicates that the issue is that collate is not checked. The only workable solution is to set the copies to 1. Sounds like a Henry Ford answer.  You can get any colour you like, as long as it is black. You can print as many copies as you like as long as the number of copies is 1.

Update: This is fixed in Visio 2010 (almost). Though the printing is correct, it appears that you get an extra page if you duplex a document with an odd number of pages. An even number of pages prints fine with no extra page.

Something New for Visio 2010 – Containers

Have you ever wanted to add an area around a group of shapes? For example, you want to identify a group of computers that belong to the draughting department? Simple, you just draw a shape around a group of shapes, but the problem arises when you want to expand or shrink the shape that encloses the group of shapes.

With Visio 2010, is a new concept called containers that will automatically stretch or shrink depending on the shapes contained.

MSO Shapes and Visio

Though not directly Visio related, I have been playing with converting the MSO shapes used in Word, Excel, PowerPoint and Publisher into Visio shapes. The shapes are similar to Visio shapes and include control handles. So far I have created a Visio stencil for the shapes and have added some of the smarts into the shapes. I have been able to create Visio drawings from MSO shapes in PowerPoint and transfer some of the settings for the shapes. The fun has been getting around the MSO*mixed types. (It basically indicates that you have to go down another path to search for your information)

 

One thing I noticed is that five of the MSO shapes return the wrong shape type. They are:

110 

msoShapeLineCallout2

109

msoShapeLineCallout1

117 

msoShapeLineCallout1NoBorder

113

msoShapeLineCallout1AccentBar

118 

msoShapeLineCallout2NoBorder

113

msoShapeLineCallout1AccentBar

121 

msoShapeLineCallout1BorderandAccentBar

109

msoShapeLineCallout1

137 

msoShapeBalloon

106

msoShapeRoundedRectangularCallout

 

Visio 2010 – Developer Mode

With Office 2007, the main apps introduced the ribbon and with Office 2010, Office introduced the ability to customize the ribbon. Since the ribbon was a major shift in the UI experience, it made sense that  only the key apps should “test the waters” and the other apps should wait till the next release. It was basically a “too many cooks spoil the broth” scenerio.

With Visio 2010, Visio acquired the Ribbon AND ribbon customization.  One problem with menus in Visio 2007 was their placement was not optomized and it was possible to leave gaps. So the introduction of the ribbon meant a better placement of the buttons and only displaying the relevant ones. (Of course, relevancy is subject to interpretation)

With the introduction of the ribbon, there were some major changes in the UI. One noticable one is the removal of the “Use Developer Mode” checkbox in the Options menu. The user can now directly customize the ribbon to enable the buttons that were added by the old “Use Developer Mode” option checkbox.

There is an alternate way to get to code. On the View tab, the last group is Macros. You can then access or create VBA macros.

VRU / IVR

A recent post in the newsgroups asked about a stencil for IVR. IVR – Interactive Voice Response – is the system we have known to love as the automated telephone system – Press 1 for customer service rep, 2 for sales and so on. A VRU Voice Response Unit is the computer that runs the software.

In a past life I maintained an IVR system for a bank and of course, documented it with Visio. Except for a few specialized shapes, most of the shapes were from the flowchart stencil. With Visio 2007, some of the workflow shapes could have come in handy. So the specialized shapes I used were:

A Decision Box – This box contained the prompt presented the user and ten connection points to the possible responses ( 0 to 9)

A CSR shape – Customer Service Rep (aka operator) This was just a piece of clipart of an operator with a headset. Since this was a common destination when the user pressed 0, it was placed in many places on the flowchart. (I wonder if I can talk Visio Guy into creating one of his people shapes for this?).

A manframe shape – The actual VRU was an OS2 box, but all the data was stored on a mainframe.

A fax machine – One of the features we added was the ability to have your bank statement faxed to your fax machine.

So I will try and put a VRU / IVR stencil together and post it on the Visio MVPS website. If anyone can come up with any additional shapes that would be useful for the stencil, let me know.

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

Will that be Metric or Imperial?

For a long time Visio has supported stencils and templates in two different measurement system; Imperial (US) and Metric. Each template had a US version and a Metric version. So why two templates? The US templates were in in, ft, yds and the other imperial units and the Metric templates were in mm, cm, m and the other metric units. There was also an isue of the physical page size; Some of the standard sizes for the US are letter, legal and tabloild while the metric sizes were the A format sizes like A3 and A4.


So is it possible to have a single template that will handle both Imperial and Metric units and paper sizes? Yes, with a few minor changes, you can combine both units.


One method to do this is to add a user defined cell to the document and use that variable to determine the system to use. To add a document level user defined cell, right click the top entry in the Drawing Explorer and select Show ShapeSheet or right click the drawing surface outside the drawing and hold the shift key while selecting Show ShapeSheet. If you do not hold down the shift key, you will get the shapesheet for the page. Add a rowl to the User Defined Cells section and name it something like UseMetric. Use a value of 0 for Metric units and non zero for Imperial units.


On each page set the PageHeight, PageWidth, PageScale and DrawingScale with a formula like.


For Page Width set the content to:    = IF(TheDoc!User.UseMetric=0,210mm,8.5in)


As you change the value of UseMetric, the PageWidth (and other qualities) will reflect the selected units.


This will give you a document that will switch between a letter size drawing in inches and an A4 drawing in mm.


The next step would be to add unit agnostic formulas to your shapes.


If you already have background pages created in Imperial units and metric units, rather than trying to merge the two with formulas based on TheDoc!User.UseMetric, combine the two background pages by applying each page to a layer and use TheDoc!User.UseMetric to control the visibilty of each layer.

Whose your father?

Visio does provide an option for printing shapesheets but it is wordy. In the past I have used Excel to sort and manipulate the information, but this is time consuming and really does not give me everything I want. One thing that was not easy to do was to find out whether a shapesheet was part of a group and if so, which group it belonged to. Being Visio, this is not a big problem. The object model is exposed and it is possible to write your own version of the shapesheet print Add-in with a routine to show the lineage of a shapesheet. 


Given a Visio shape, this function will return a string that lists its’ ancestors. 


Private Function Heritage(shpObj As Visio.Shape) As String


Dim Finished     As Boolean
Dim tmpName   As String
Dim tmpString   As String


tmpName = shpObj.Name
tmpString = tmpName


Finished = False
Do While Not Finished


    If ActivePage.Shapes(tmpName).Parent.Type = visTypeGroup Then
        tmpName = ActivePage.Shapes(tmpName).Parent.Name
        tmpString = tmpName + ” ” + tmpString
    Else
        Finished = True
    End If
   
Loop


Heritage = tmpString


End Function


This sample code will eventually make it’s way over to http://visio.mvps.org/VBA.htm