August 22, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Using Visual Studio Tools for Office in Visual Studio 2008

  • April 28, 2008
  • By M. Rajesh
  • Send Email »
  • More Articles »

This article will help you to get started with the new Ribbon interface in Microsoft Office 2007. The Ribbon interface is new to Office 2007. So. see what it means for the developer's community to create solutions for Office 2007 using the Ribbon interface. This means that the developer needs to have special tools to create applications that make use of the Ribbon interface. Microsoft has answered the developers' wishes by releasing the updated version of Visual Studio Tools for Office in Visual Studio 2008.

Visual Studio 2008 includes the third version of Visual Studio Tools for Office (VSTO), a set of libraries and designers for developing applications, and add-ins for Microsoft Office 2003 and 2007. This is the first time VSTO has been bundled into Visual Studio, and it also represents a significant step forward in usability, a major factor in getting .NET programmers to adopt Office as a platform.

Before you go through a sample walkthrough on creating applications that make use of the Ribbon interface with Visual Studio 2008, please take a walk through history and see how Microsoft Office came to be used as a major tool for presenting data from business applications and why it remains one of the most powerful tools when it comes to automating tasks as well as presenting data from a variety of data sources.

Visual Basic for Applications

This is the first release that Microsoft developed long ago and has been a critical part of Microsoft Office until .NET came into the picture.

Visual Basic for Applications (VBA) was a simple development environment integrated into all the Office applications. Each Office application had a rich object model that was accessed via a technology known as COM. Millions of developers identified themselves as "Office developers" and used VBA and the Office COM object models to do everything from automating repetitive tasks to creating complete business solutions that leveraged the rich features and user interface of Office. These developers realized that their users were spending their days in Office. By building solutions that ran inside Office, they not only made their users happy, but also were able to create solutions that did more and cost less by reusing functionality already available in the Office applications.

Visual Basic for Applications is an implementation of Microsoft's Visual Basic, an event-driven programming language and associated integrated development environment (IDE) that is built into most Microsoft Office applications. By embedding the VBA IDE into their applications, developers can build custom solutions using Microsoft Visual Basic. It was also built in to Office applications up to version 2004 for Apple's Mac OS X, other Microsoft applications such as Microsoft MapPoint and Microsoft Visio; as well as being at least partially implemented in some other applications such as AutoCAD, WordPerfect, and ArcGIS. It supersedes and expands on the capabilities of earlier application-specific macro programming languages such as Word's WordBasic, and can be used to control almost all aspects of the host application, including manipulating user interface features, such as menus and toolbars, and working with custom user forms or dialog boxes. VBA can also be used to create import and export filters for various file formats, such as ODF.

As its name suggests, VBA is closely related to Visual Basic, but can normally run code only from within a host application rather than as a standalone application. It can, however, be used to control one application from another using OLE Automation. For example, it is used to create a Word report automatically from Excel data, in turn automatically collected by Excel from polled observation sensors.

VBA is functionally rich and extremely flexible, but it does have some important limitations, including limited support for function pointers that are used as callback functions in the Windows API. It has the ability to use (but not create) (ActiveX/COM) DLLs, and later versions add support for class modules.

VSTO 2003

With the advent of .NET in 2001 and the bridge between the managed and unmanaged world, Microsoft realized that VBA wouldn't stand on its own in the world of managed code. So, it realized that it would have to develop a new mechanism of integrating with Microsoft Office and enable developers and users to integrate Office within their business applications.

The first version of VSTO was simple, but it accomplished the key goal of letting professional developers use the full power of Visual Studio .NET and the .NET Framework to put code behind Excel 2003 and Word 2003 documents and templates. It let professional developers develop Office solutions in Visual Basic 2005 and C#. It solved the problem of embedded code by linking a document to a .NET assembly instead of embedding the .NET assembly in the document. It also introduced a new security model that used .NET code-access security to prevent worms and macro viruses.

Reasons for moving from VBA to VSTO

The following reasons explain what a developer gains when moving from a VBA environment to VSTO environment. There are many benefits when you migrate from VBA to Visual Studio 2005 Tools for Office, but for simplicity only the top benefits are listed below.

  • Improved development productivity: One reason to migrate from VBA to Visual Studio 2005 Tools for Office is to gain access to the integrated development environment between Visual Studio 2005 Tools for Office and Microsoft Visual Studio 2005. Visual Studio is one of the richest and most sophisticated development environments available, increasing coding and testing productivity. Although Visual Studio 6.0 also has one of the best debugging tools in the world, it is not enough to solve all issues related to the runtime environment of VBA. For example, it is hard to debug the environment when they run as a standalone application. Also, the famous DLL Hell at the client's place makes it hard to pinpoint the cause of the error.
  • Improved security model: Back in the days of COM, there was not much reason to fear for security and worries about malicious code written by developers. Most applications could be trusted by the users and they didn't pose security risks to the environment in which users ran their applications. Also, the VBA applications/components ran with full trust; this meant that they had access to the user's file system, on which the application ran. Therefore, the application could do lot of things without the user's knowledge. With the advent of the Internet, things changed a lot and users had to be cautious before running applications from external sources on their computers. Applications written in VSTO benefit from the security model built into the common language runtime (CLR) because they run in a trusted domain and cannot access the file system of the user.
  • Easier deployment and versioning: Because one of the primary benefits of the CLR is "no more DLL Hell," this means that the user can create multiple versions of the same application and run them on the client side without having to worry about conflicts and the like. Managed solutions allow more flexible deployment options and simplified deployment and updates.
  • Added functionality from the.NET Framework: Because VBA is built on the Visual Basic language and Visual Basic 6.0 and earlier didn't support OOPS, this meant that inheritance and reusability couldn't be implemented. The developer had to write all the functionalities over and over, thereby bloating the size of the application. Having access to the Base Class Libraries of the CLR allows you to use its new features such as XML readers, ADO.NET, and simplified consumption of Web services.
  • Improved code reuse: Because Visual Basic .NET is a fully object-oriented language, this facilitates code reuse and hence can be used to build the building blocks for reuse in other applications.
  • Easier integration: The.NET Framework facilitates integration with other applications using Web services.




Page 1 of 7



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel