Tip

Migrating add-ins from VBA to VSTO

Years after the release of the .NET Framework, many developers are sticking with VB 6 applications developed in VBA. Many of these apps tend to work with only an occasional hiccup, while some are so involved that a quick and easy migration to .NET is nearly impossible.

The combined power of Visual Studio 2005 Tools for Office (VSTO) and Office 2007 may be enough to convince many developers to move to .NET.

With VSTO, Word and Excel are incorporated directly into the Visual Studio IDE, developers have access to .NET's vast class libraries, and there is support for IntelliSense and debugging. In Vista, meanwhile, menus, toolbars and task panes have been replaced with a customizable UI element called the ribbon, which displays the most frequently used commands.

A large concern here is getting those old VBA solutions into VSTO. How difficult will it be? What will happen to the solution once it becomes a VSTO add-in? What will and will not work?

Jan Fransen of MCW Technologies addresses these issues in the recent MSDN article, Migrating a VBA Solution to a Visual Studio Tools for Office Add-In.

The author begins by noting that not all VBA solutions should be migrated to VSTO. "If a solution has been running well for years and you do not plan to add anything new to it, it is probably best to leave it where it is," Fransen writes. On the other hand, "If you design something new, or plan major enhancements to an existing solution, or if you would like to change a document-level solution into an application-level solution, you should look carefully at what [VSTO] offers."

More on Office 2007 development
Tip: How to customize the Office 2007 Ribbon

Tip: Using Microsoft Office as a development platform

Reference: Visual Studio 2005 Tools for Office Learning Guide

From there, Fransen describes his sample VBA solution and then goes through the steps necessary to migrate it to VSTO Second Edition (the version that works with Windows Vista). Topics covered along the way include Windows Forms controls, working with Web services and displaying a custom task pane.

Fransen provides both VB and C# sample code throughout the article. He also notes that familiar VBA constructs and functions will still work in VSTO.

"[I]f you are new to the .NET Framework, you might find it easier to use the VBA-style functions (such as MsgBox) and constructs (such as With…End With) that are still available to Visual Basic programmers," Fransen writes. "If you write in Visual Basic but are interested in using the .NET Framework whenever possible, take a look at the equivalent C# code for each example."

This was first published in November 2006

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.