Getting Started: Developing with Visio 2003

 

Saul Candib
Microsoft Corporation

July 2004

Applies to:
    Microsoft Office Visio Standard 2003
    Microsoft Office Visio Professional 2003

Summary: There are many approaches to developing extensions for Microsoft Office Visio 2003 or integrating Visio with other applications. This article summarizes the technologies for development for Visio and points to resources for specific information and sample downloads. (5 printed pages)

Contents

Introduction
Solution Development
Shape Development
Visio Drawing Control Development
Save as Web Page Development
XML Development
The Visio 2003 SDK
Additional Resources

Introduction

You can extend Microsoft Office Visio 2003 in several ways, either programmatically or by integrating it with other applications. Development in Microsoft Office Visio 2003 Standard Edition or Microsoft Office Visio 2003 Professional Edition can take the following forms:

  • Solution development
  • Shape development
  • Visio Drawing Control development
  • Save as Web Page development
  • XML development

This article summarizes these areas of development and provides links to documentation and sample code to get you started developing with Visio.

Solution Development

A Visio solution typically combines Visio shapes and programs that model the real world and solve specific drawing problems. Programs can help create a drawing, analyze a drawing, transfer information between the drawing and an external data source, or recognize events as they occur in the application.

You can use the following technologies individually or in combination to create Visio solutions:

  • Microsoft Visual Basic for Applications (VBA)   The built-in VBA macro recorder and Integrated Development Environment (IDE), called the Visual Basic Editor, enable you to create simple macros to automate repetitive tasks. You can also develop simple or complex extensions that integrate Visio with other applications such as Microsoft Office Word 2003 and Microsoft Office Excel 2003 in the Microsoft Office System, and the hundreds of other applications that include VBA.

    VBA Help, in the form of the Microsoft Office Visio 2003 Automation Reference, is built into Visio Standard and Visio Professional; it documents and explains how to use the properties, methods, events, and objects in the Visio object model. The Automation Reference is also available as part of the Microsoft Office Visio 2003 SDK.

  • COM add-ins and Visio add-ons   A Component Object Model (COM) add-in provides new functionality to Visio, such as a custom dialog box that is accessed from a new menu item and adds new features. A Visio add-on is a user-written program that extends Visio functionality. An add-on can be one of two file types and can be implemented in one of two ways—in a Visio library file (a .vsl file), which is a form of dynamic-link library that is Visio-specific, or in a standalone executable program (an .exe file).

    The Microsoft Office Visio 2003 SDK includes two wizards that you can use to create add-ons and add-ins: the Microsoft Visual Studio .NET 2003 Visio Add-in Wizard, which creates a shell add-on or add-in project in Microsoft Visual Studio .NET 2003, in Microsoft Visual Basic .NET, in Microsoft Visual C#, or in Microsoft Visual C++; and the Microsoft Visual Studio 6.0 C++ Visio Add-on or Add-in Wizard, which creates a shell add-on or add-in project in Microsoft Visual C++ 6.0.

    In addition, the Visio 2003 SDK includes Microsoft Visual Basic 6.0 project templates for creating an executable program that runs as an add-on in Visio and a COM add-in to run in Visio. Projects based on these templates contain basic Visio support, help speed the development process, and show suggested practices for creating Visio add-ons and add-ins in Visual Basic.

    For more information about creating add-ons and COM add-ins in Visio, see About Microsoft Office Visio Add-ons and COM Add-ins in the Visio 2003 SDK.

  • Managed code   You can use the Primary Interop Assembly (PIA) that is installed with Visio 2003 to integrate the COM-based Visio object model with managed-code assemblies and applications that are developed with Visual Basic .NET, C#, and other languages that use the Microsoft .NET Framework.

    Normally, you install the Visio 2003 PIA when you install Visio on your computer. To determine whether it is installed, you can open the global assembly cache as follows: On the Windows Start menu, click Run, and then type assembly in the drop-down list box, and then click OK. This action opens the assembly window, in which you should see Microsoft.Office.Interop.Visio listed, along with the other PIAs for the Microsoft Office 2003 applications that are installed on your computer.

    If you don't see the Visio PIA in the global assembly cache, see How to: Install Office Primary Interop Assemblies. For more information on using the .NET Framework to extend Microsoft Office applications, see Managed Code and Office Programming with Visual Studio .NET.

    The Visio 2003 SDK includes a Managed Code Tutorial. The tutorial consists of four lessons that walk you through creating a Visio COM add-in. Each lesson is a COM add-in sample application written in Visual Basic .NET. The COM add-in automatically generates a flowchart from end-user data collected by a custom Visio wizard. Each lesson takes the sample application one step forward.

  • Integrating Visio with other applications   By integrating Visio with other Office applications, you can create rich solutions. For example, to learn how you can integrate Visio with Microsoft SharePoint Products and Technologies, see Integrating Microsoft Office Visio 2003 with Microsoft SharePoint Products and Technologies.

Shape Development

Everything in Microsoft Office Visio 2003—every document, page, style, shape, group, shape or object within a group, master, object from another program, guide, and guide point—has a ShapeSheet spreadsheet where information about that object is stored. This spreadsheet contains information such as height, width, angle, color, and other attributes that determine the shape's appearance and behavior.

Shape developers need precise control over the appearance and behavior of the shapes they create. As a shape developer, you can change a shape's default behavior and enhance what it can do by editing its ShapeSheet, which you can access programmatically or in a ShapeSheet window in the Visio user interface (UI).

For more information about shape development, see the ShapeSheet Reference, which is built into Visio and which is also available as part of the Visio 2003 SDK.

The SDK also includes ShapeStudio, which is a development and productivity tool for people who design and develop Visio shapes. ShapeStudio provides a custom work environment in Visio that facilitates project management, specification and design, development, and verification of SmartShapes. All the data associated with ShapeStudio projects is stored independently in a database—not in the Visio document—making shape maintenance and version control much easier.

For more information about ShapeStudio, see the ShapeStudio documentation in the Visio 2003 SDK download.

Visio Drawing Control Development

The Microsoft Office Visio Drawing Control 2003 is a Microsoft ActiveX control that provides full access to the Visio object model (API) and user interface so that you can integrate the Visio drawing surface and UI into your applications, customize its appearance, and automate Visio in your applications. The Visio Drawing Control is provided with both Microsoft Office Visio Standard 2003 and Microsoft Office Visio Professional 2003 and is installed when you install Visio.

For more information about the Visio Drawing Control, see the Automation Reference in the Visio SDK. Further information is available in the following articles on MSDN:

For managed-code development, the Visio Drawing Control has its own PIA, Microsoft.Office.Interop.VisOcx.

Save as Web Page Development

The Visio Save as Web Page feature provides users with a simple way of publishing Visio documents on the Web. The Save as Web Page API gives you programmatic access to this feature, enabling you to save a Visio drawing as a Web page without exposing the user to the Save as Web Page dialog boxes in the user interface. For more information, see the Help topics in the Save as Web Page Reference in the Visio SDK.

For managed-code development, the Visio Save as Web Page API has its own PIA, Microsoft.Office.Interop.Visio.SaveAsWeb.

XML Development

XML (Extensible Markup Language) is the universal format for structured documents and data on the Web. A DataDiagrammingXML (formerly XML for Visio) file is an XML document that contains all the components of a Microsoft Office Visio binary file. Much as you can access a Visio document by using Automation or from the ShapeSheet window, you can use XML and supporting tools to access data in a DataDiagrammingXML file.

For more information about developing in Visio with XML, see the XML Developer Center on MSDN. You can also download the entire Office XML Reference Schemas file and related documentation from Microsoft, including the DataDiagrammingXML schema.

The Visio 2003 SDK

The entire Visio 2003 SDK is available as a download on Microsoft. The full download includes the following:

  • Tools   Customization and extensibility tools to increase your productivity and reduce development time. These tools include the Persistent Events, Print ShapeSheet, Solution Publishing, and Event Monitor tools, as well as ShapeStudio, a complete user interface for developing Visio shapes.

    The SDK also includes wizards to set up new Visio add-ons and Component Object Model (COM) add-ins in Microsoft Visual C#, Microsoft Visual Basic .NET, Microsoft Visual C++, and Microsoft Visual Basic.

  • Sample applications   Samples that you can experiment with and use to acquaint yourself with Visio features. These sample applications are written both to demonstrate aspects of developing on the Visio platform and to be used as a starting point for your custom applications. The samples include the Flowchart, Tree View, and Office Plan sample applications, as well as the Managed Code Tutorial.

  • Code Librarian   A database of reusable methods, classes, and procedures for Visio in Microsoft Visual C#, Microsoft Visual Basic .NET, and Microsoft Visual Basic 6.0.

    You can view and copy all of the code samples provided in the Microsoft Code Librarian Viewer, which is included with the SDK.

  • Library files   Type libraries for the APIs that Visio exposes as well as C++ library helper files.

  • Documentation   The full set of Visio references and articles, including the Automation Reference, ShapeSheet Reference, Save as Web Page Reference, and XML Reference.

Additional Resources

Development for Visio 2003 goes well beyond Visio itself. The Microsoft Office Developer Center has a wide variety of information about development for all products in the Microsoft Office System and integration with other products. The Visio Developer Center includes links to technical articles, updated SDK documentation, related resources, and Visio newsgroups.

Various third-party books are available that contain valuable information about developing with Visio.

It is also important for any developer of a solution that involves Visio 2003 to understand Visio itself. The Visio home page on Microsoft Office Online includes many resources for assistance, training, templates, articles, case studies, downloads, and information on how to use Visio 2003.