Displaying Inches as Fractions

I was recently asked if the Size & Position Window in Visio can display fractions of inches as fractions rather than as decimals.  Well, most people are aware than you can type fractions into the Size & Position Window, but it is immediately translated into decimals, and I cannot find any way to keep the display as fractions, however you can link Shape Data (nee Custom Properties) to the width and height.

In the image below, I have added two Shape Data rows (Prop.Width and Prop.Height) and I have linked the values of the rows to the shape’s Width and Heights with the formulae =SETATREF(Width) and =SETATREF(Height).

image

These formulae mean that any values typed into the Shape Data Window are immediately re-directed to the shape’s Width and Height cells, and the format picture ="# ##/## u" ensures that the values are displayed as fractions.

Moreover, values can be typed into either the Size & Position Window or the Shape Data Window.

In the above example, I also chose to display the Width and Height values in the text of the shape using the FIELDPICTURE(18), which displays the result as fractions.

P.S.  I’m old enough to remember Feet and Inches being called Imperial Units … it’s a sign of the times that they are now called US Units!

Visio Viewer Developer Reference Released

Following on from my blog about the Microsoft Visio Viewer, I am delighted that Microsoft have published a developer reference for it (long overdue, but very welcome).  See the MSDN pages at http://msdn.microsoft.com/en-us/library/cc297217.aspx and Visio Insight blg http://blogs.msdn.com/visio/archive/2009/01/14/developer-reference-for-visio-2007-viewer-released.aspx

Turning OFF The Cross Functional Flowchart Addon in Visio

Following on from my last blog, my colleague also needs to stop the Cross Functional Flowchart behaviour in a Visio Diagram.  Well, I was almost fooled again into thinking that it might be as simple as removing the Persistent Events using the tool in the Visio SDK.

image

Well, deleting them was no problem, but the DocumentOpened event was re-added as soon as the document was saved.  A little investigation revealed that there are 56 EventList items in a Cross Functional Flowchart diagram (after deleting the two PersistentEvents), but only 44 in a standard Visio document (on my Visio 2007 Pro installation).  So, there are an extra 12 that have been added … just ready to spring back into life when the actions they are listening to are fired.  One of these must be the DocumentSaved event, so simply disabling the events before saving (and remembering to switch them back on), allowed me to remove the Cross Functional Flowchart add-on.

One caveat, dragging a Functional band master back onto a page will switch it back on again.

Public Sub RemoveCFF()
Dim evt As Visio.Event
Dim i As Integer
    For i = Visio.ActiveDocument.EventList.Count To 1 Step -1
        Set evt = Visio.ActiveDocument.EventList.Item(i)
       If evt.Persistent = True Then
            If evt.Target = "CFF"
Then
                Debug.Print evt.Target
                evt.Delete
           
End If
        End If
    Next

    On Error Resume Next
    Visio.Application.EventsEnabled = 0
    Visio.ActiveDocument.Save
    Visio.Application.EventsEnabled = -1
End Sub

Closing Shape Data Sets window in Visio 2007

A colleague recently asked me how to close the Shape Data Sets window so that it does not automatically re-open when you open the drawing again.  My first thoughts was that this is surely a simple matter of saving the workspace, but it appears that this is not the case!  I found that other Visio users have had the same problem, so I thought I would present my solution (until Microsoft fix it!).

image

The window is opened from the right mouse menu of the Shape Data window.

image

The Shape Data Sets window has a right-mouse menu option to Close it, and it has the normal X button to close it.  Indeed, this does hide the window, but it automatically re-opens whenever the document is re-opened.

A little investigation reveals that the add-on; named "cpm" for Custom Property Management, I guess; creates two persistent events in the document, a SolutionXMElement, and User-defined cell.  So, I found it necessary to write a macro to remove all of these items from the document.

Public Sub CleanShapeDataSets()
Dim win As Visio.Window
    For Each win In Visio.ActiveWindow.Windows
        If win.Caption = "Shape Data Sets" Then
           win.Visible = False
           win.Close
        End If
    Next
    If
Visio.ActiveDocument.SolutionXMLElementExists("CustomPropertySets") Then
        Visio.ActiveDocument.DeleteSolutionXMLElement "CustomPropertySets"
    End If
    If
Visio.ActiveDocument.DocumentSheet.CellExists("User.CPMState", Visio.visExistsAnywhere) Then
        Visio.ActiveDocument.DocumentSheet.DeleteRow Visio.visSectionUser, Visio.ActiveDocument.DocumentSheet.Cells("User.CPMState").Row
    End If
Dim
evt As Visio.Event

Dim i As Integer
    For i = Visio.ActiveDocument.EventList.Count To 1 Step –1

        Set evt = Visio.ActiveDocument.EventList.Item(i)
        If evt.Persistent Then
            If evt.Target = "cpm" Then
                evt.Delete
            End If
        End If
    Next
End Sub

The macro can be stored in any Visio document, but just run it when you want to permanently close the Shape Data Sets window on the active document.

Posted in Visio. 1 Comment »
Follow

Get every new post delivered to your Inbox.

Join 206 other followers