Learning Path For Visual Studio Tools For Office (VSTO) Programming

Let's go through some important pointers that will be helpful for Visual Studio Tools for Office (VSTO) programming.

Introduction / Overview of VSTO

  • Consists of a managed code assembly that is associated with a Microsoft Office application
  • Can use Visual Studio tools for developing VSTO Add-ins
  • Can use any of the classes in the .NET Framework.
  • Add-in projects include an automatically generated class that represents the VSTO Add-in
  • Class provides properties and events that can be used to access the (office) object model
  • Other Visual Studio features such as Windows Forms and an integrated debugger are available

    For more information refer.

Components of VSTO Add-ins

  • Registry Entries

    • Microsoft Office applications discover VSTO Add-ins by looking for a set of registry entries
    • On build, Visual Studio creates all of the required registry entries on the development computer
    • ClickOnce , the Setup program generated by the publish process, automatically creates the registry keys on the end user computer

  • Deployment Manifest and Application Manifest

    • Being used to identify and load the most current version of the VSTO Add-in assembly
    • Deployment manifest points to the current application manifest
    • Application manifest points to the VSTO Add-in assembly, also, specifies the entry point class to execute in the assembly

  • Visual Studio Tools for Office Runtime

    • To run VSTO Add-ins, end user computers must have the Visual Studio Tools for Office runtime installed
    • Includes unmanaged components that load the VSTO Add-in assembly
    • and, set of managed assemblies that provide the object model, use to automate and extend the host application.

      For more information on how it works.

Office Application Object Models

  • Developing Add-ins, we need to interact with the office application object model
  • This object model consists of classes and interfaces that are provided in the primary interop assembly for office application

Excel Model Object

  • Application - represents the Excel application itself
  • Workbook - represents a single workbook within the Excel application.
  • Worksheet - is a member of the Worksheets collection
  • Range - represents a cell, a row, a column, a selection of cells within your Excel application
    For more information.

Word Model Object , below are top-level objects and how they interact with each other.

  • Application - represents the Word application, and is the parent of all of the other objects
  • Document - represents a document and all of its contents
  • Selection object - represents the area that is currently selected
  • Range object - represents an area in a document, and is defined by a starting character position and an ending character position.
  • Bookmark object - represents an area in a document, with both a starting position and an ending position
    For more information.

Types of Programming Add-ins

  • Document Level Add-in

    • The code will be Loaded and Executed when specific Document/Worksheet is opened.
    • The code will  be Unloaded when the corresponding Document/worksheet is closed.
    • The add in can respond to events and extend the specific Document/Worksheet.
    • The add in is loaded per document/worksheet and when any error occurs other documents/worksheets can continue working.
    • Document level add in supports customizations works only for Word and Excel
    • Features specific to Document Level Add ins are: Action Pane, Data Cache.
      For more information on Programming Document-Level Customizations.

  • Application Level Add-in

    • The code will be Loaded and Executed when a new Instance of Word/Excel is opened. (either by using Programs menu or while opening a document).
    • The code will be Unloaded When the Word/Excel Instance is closed.
    • The add in can access all the document/worksheets of the associated Instance.
    • The add in is loaded per application and if any error occurs, then all documents inside the Instance will be affected.
    • Application Level Add in supports: Word, Excel, PowerPoint, Outlook, InfoPath, Project and Vision.
    • Features specific to Application Level Add ins are: Custom Task Pane, Outlook Form regions.
      Programming Application-Level Add-Ins
      .

Deployment

Summary

Visual Studio Office Development plays a vital role in wide workflow scenarios for small, large, independent enterprise. Learning VSTO programming will surely add stars to your skill set, allowing to leverage your web and windows components to powerful Office products. I hope the above pointers will help you master VSTO skills.

Very best of luck and Happy Coding!


Similar Articles