Working with Visio drawings in VS.NET

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 iLearning.com, where he writes and teaches on a variety of subjects, including markup languages, development tools and IT certifications. Contact Ed via e-mail at etittel@lanw.com.

This was first published in February 2003

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.