Problem solve Get help with specific problems with your technologies, process and projects.

Working with Visio drawings in VS.NET

Ways to do it, and avoid problems.

Let other users know how useful this tip is by rating it below. Got a tip or code of your own you'd like to share? Submit it here!

For lots of applications, access to simple diagrams, line drawings, and so forth can be pretty desirable. As you'd expect when moving data from one Microsoft tool to another, there's more than one way to use Visio-based drawings or diagrams within .NET-enabled code, and there are sometimes problems that can pop up when saving data from Visio to re-use later within applications.

To begin with, you may benefit most quickly and directly from Visio based files if you simply incorporate the Visio Viewer Web Component in any Web-based application. This simply requires integrating a freeware ActiveX software component into other applications that Microsoft provides so that those who don't have Visio installed on their computers can nevertheless open and interact with Visio files. The only stipulation is that such files must be in Visio .vsd (Visio drawing) or .vsx (Visio XML stencil) formats. By using the Visio Viewer Web Component, you can then view Visio documents in Internet Explorer version 5 (or later) implementations. The following capabilities become available in this context:

  • Pan and zoom in the Drawing window using various controls (toolbar buttons, keyboard shortcuts, or shortcut menu entries).
  • Inspect properties on top-level shapes using the Properties and Settings dialog box and selecting a shape.
  • Manage some limited rendering and display settings as available through the Display Settings tab and the Properties and Settings dialog box.
  • Print Visio drawings from Internet Explorer.

For more information on this component, visit KB article 312849. (You will also find links to download the component there as well.)

Those building XML-based applications can also internalize Visio documents saved in .vdx (Visio XML drawing format) or .vsx (Visio XML stencil format) forms. This means you must of course save your work from Visio in one of these formats, a process that's not without some apparent potential gotchas. When saving a Web site map diagram from Visio as a stencil or XML stencil, the program may sometimes crash. This is most likely to occur when using the Save As command from the program's File menu. Should that happen, the following workaround will prevent its recurrence:

  • On the Visio File menu, select Stencils, then click New Stencil.
  • Open the Filter window from the lower left border of the Web site map drawing area.
  • Click the plus sign beside each shape in the Filter window to expand that group.
  • Drag all shapes you want to save from the Filter window into the new stencil.
  • When finished, right-click the stencil title bar, then click Save.
  • In the Save as Type text box, click Stencil (*.vss) or XML Stencil (*.vsx), specify file name, location, etc., then click Save.

This should avoid the problem entirely.

Savvy VS developers can make good use of Visio drawings, diagrams and site maps. This tip will help them do so, and avoid known pitfalls in the process.

Ed Tittel is a principal at LANWrights, Inc. a wholly-owned subsidiary of, where he writes and teaches on a variety of subjects, including markup languages, development tools and IT certifications. Contact Ed via e-mail at

Dig Deeper on Smart client application development best practices

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.