Andrei Smolin

Migrate the code of your Office solution from Win32 and VBA code to .NET

Advantages of the .NET platform

As you probably know the .NET Framework provides a number of advantages when compared to Win32 programming. Say, administrators have by far more control over your code – they may restrict your code to use these or those resources or permissions. While it puts some limits on developers, companies are able to build environments that are safer and more controllable. Another advantage is the availability of all programming features for all languages: you can do anything in VB.NET or in C# that requires using C/C++ in Win32 programming. Amongst other advantages we’d mark out ClickOnce – deployment technology targeted to non-administrative installations.

Of course, the .NET platform has many advantages, but if you are doing Office development, you should be aware of its weak points as well. Many think that the main disadvantage is a relative slowness of .NET based code when compared to the same program written in Win32. Yes, we have to agree with that, but a wide market, more powerful computers, and the .NET Framework availability compensate this.

Difficulties of migrating the code from Win32 or VBA to .NET

What are real drawbacks of .NET then? The main disadvantage is another model of object releasing. If you have written in Delphi or VB for years, but have never programmed in .NET, you will be unpleasantly surprised by the fact that setting a .NET variable referencing a COM object to null, nil or Nothing doesn’t release the COM object. To be precise, it isn’t released immediately. And this may be a real problem. In fact, when you are using .NET, Office still remains Win32 and COM based software. That is why releasing every COM object that you create in your code is a must. To do this, you should consistently and systematically use a special method of the Marshal class located in the System.Runtime.InteropServices namespace in the .NET Framework. The method is called ReleaseComObject.

We know about this “feature” very well, our daily support brings us a lot of problems that occur when COM objects are not released in a timely manner. That is why I thought it was a good idea to publish my answers to frequently asked questions about releasing COM objects when programming Office add-ins on our blog.

What we do is create products purposed for speedy development of the infrastructure of your COM add-in, Excel Automation add-in, XLL add-in, RTD server, or Smart Tag. The infrastructure includes the UI and entry points for your functionality, as well as a setup project for your solution. The products are tested by a really great number of developers. Custom solutions built on our products work with all Office versions on thousands of PCs all over the world.

As you probably know, Office programming is a tricky area. And we work in this area for years. We do know a lot of things: object models, Office bugs and workarounds, functionality and inner structure of Office windows. After we had mastered all this stuff, we came up with a nice feature that is highly appreciated by developers who create COM add-ins for Outlook, Excel and Word. The feature is custom task panes available for all Office versions: from 2007 down to 2000.

We can port your Win32 VCL or VBA code to .NET

If you are thinking about creating a new proof-of-concept Office COM add-in, RTD server, Excel UDF, smart tag, IE add-on, Outlook Express plug-in or migrating your Win32 or VBA Office extension to .NET, we can develop the infrastructure of your solution: command bars and command bar controls, Ribbon controls, Office 2007 menu, custom panes, and such. Also, the solution can include a trivial processing of event handlers.

If you need just this: clicking on this button shows my pane, we can do it very quickly, say in a day or two.

If you need anything more complex, please use this form to send me detailed requirements. We can develop in VB.NET or in C# as there is no difference in languages in .NET. Our statistics says that people prefer C#. What is your choice?

Regards,
Andrei Smolin
Add-in Express Team Leader

Post a comment

Have any questions? Ask us right now!