Using the Microsoft Visio Viewer (and introducing visViewer)

Microsoft Outlook 2007 installs the Microsoft Visio Viewer (vviewer.dll via vpreview.exe) by default (see http://office.microsoft.com/en-us/outlook/HA102448111033.aspx#2 ), so that native Visio files can be seen in all their glory (almost).  In this blog I’ll show that the Visio Viewer actually provides access to the Shape Data (Custom Properties), Hyperlinks, Reviewers Markup and Layers.  All this without even having Visio installed!

OutlookPrePreviewVisio

This is great because multiple page documents can be browsed, panned and zoomed.

OutlookPostPreviewVisio

However, this presentation of the Microsoft Office Visio previewer hides quite a lot of its functionality of this, so it is difficult to toggle layer and reviewers markup visibility, or to view the shape data/custom properties.

There is an existing web article which demonstrates how to use the Visio Viewer in SharePoint (http://www.wssdemo.com/Pages/visio.aspx), and the same method can be used in a web page.  This presentation of the Visio Viewer does enable the user to get the extra functionality, but it does not allow the shape data to be searched, listed or extracted.  Neither does it allow you to print easily.

Well, I wrote visViewer as a vb.net wrapper for the Microsoft Visio Viewer 2003 version several years ago, and now I have updated it for the Microsoft Visio Viewer 2007 (see  http://www.bvisual.net/Products/visViewer.aspx). The newer version provides access to shapes with shapes, just as the reporting tool full version of Visio was enhanced to provide access to shapes within shapes. This time I have released it as shareware, so feel free to try it, and, if you like it and use it commercially, you may wish to donate towards its development.

visViewer demonstrates that all the Shape Data on all of the shapes on each page in the Visio document are visible to code.  The main principle is that the CurrentPageIndex of the Viewer control needs to be set to an integer number up to the PageCount before the shapes can be read.  For example the following block of code shows how you can

With Me.AxViewer1

.CurrentPageIndex = n

For lShape As Integer = 1 To .ShapeCount

‘You can use .get_ShapeName(lShape)

    For lProperty As Integer = 1 To .get_CustomPropertyCount(lShape)
        ‘ You can use .get_CustomPropertyName(lShape, lProperty)
        ‘ and .get_CustomPropertyValue(lShape, lProperty)
    Next lProperty

    For lHyperlink As Integer = 1 To .get_HyperlinkCount(lShape)
        ‘ You can use .get_HyperlinkAddress(lShape, lHyperlink)
    Next lProperty

Next lShape

End With

clip0031

Once you have read the data inside each shape, then you can provide searching and exporting.

clip0039

In addition to reading the Shape Data, I also collect the Hyperlinks, and thus it is possible to show multiple hyperlinks on shapes, and to provide the ability to follow them.

clip0049

One shortcoming of the Visio Viewer is the lack of any method to zoom to a shape in the document.  Strangely, there is a method to the shape at any xy co-ordinate (get_ShapeAtPoint), but not one to get the xy co-ordinate of a shape.

Another shortcoming of the Visio Viewer is the lack of printing, but I have been able to partially address this by using the PrintForm method from the Visual Basic Power Packs.  However, this only outputs raster, which is never going to be as crisp as vectors.

I decided to use the Microsoft ReportViewer (because it is simple and royalty free) for the reports that provide printing, or export to Excel or Pdf, of the shape data.

clip0060

Lastly, I provided the ability to open a Visio document from the menu, or by dropping a Visio document on to the Visio Viewer panel, or by opening from Window Explorer (if the msi installation is used rather than the ClickOnce).

I hope that visViewer proves useful to non-Visio and Visio users alike, and hope that it encourages the use of Visio files as a portable data graphic file format.

Seasons greetings!

Posted in Visio. 16 Comments »

16 Responses to “Using the Microsoft Visio Viewer (and introducing visViewer)”

  1. sivabala Says:

    I could not able to view files with extension .vsd even though Visio viewer is installed in my computer.

    Can anyone help me out of this?

  2. JanB Says:

    I cannot run VisViewer on W7 64 at all, it closes immediately without a solution.
    I cannot get Visio 2010 with SP1 to view a vsd-file either, it is supposed to run in IE but can’t get it running, searched Google but couldn’t find an appropriate answer which worked for me.

  3. saleem Says:

    Does Visio Viewer or visViewer allow macros to run? i ask becasuse i cant seem to get a .vsd with a button and click macro to trigger at all..

    • davidjpp Says:

      No, I am afraid not. visVieweer uses the Microsoft Visio Viewer, which is read only.
      You need to open in Visio to run a macro, and thus go through the usual security checking.

  4. San Russo Says:

    Hi
    Use Visio 2007, have created data taht links to multiple hyperlinks (seperate documents), all works fine. Problem is when a user uses Visio Viewer, they dont get the hyperlink icon on the pointer of the mouse (not a big issue) but when the select the object only one hyperlink can be opened, the none of the others appear to select.

    SR

  5. Stephen Lipp Says:

    I have inherited a project in VS2010 which has a set of Visio UML diagrams. I was hoping to at least “view” the diagrams, but when I double-click them, I get the Microsoft Office message box, “This program can only run from within another program.” Huh?

    SL


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 218 other followers

%d bloggers like this: