views:

208

answers:

4

I have to convert a C# project to VB.NET and VBA. It's a console app that uses the Microsoft Office API (Microsoft.Office.Interop.*).

My two questions:

  • C# -> VB.NET: .NET Reflector is a good tool for this, except that it doesn't preserve source code comments. Is there a way to do this?
  • .NET -> VBA: is there an automated tool to do this conversion? It would need to be a client side tool (because the code is proprietary).
+1  A: 

There are many ways to convert C# to VB.Net; for example, try Developer Fusion.

It is not possible to automatically convert C# to VBA because the environment, language, and libraries are radically different. However, you could expose the C# code as a COM server and call it from a thin wrapper in VBA.

SLaks
+1  A: 

Answer for question #1:

You cannot use Reflector to preserve source code comments because Reflector is disassembling the compiled code, which has had all comments removed.

Consider using a commercial tool like InstantVB, which will converts C# source code into VB source code (including comments): http://tangiblesoftwaresolutions.com/Product%5FDetails/Instant%5FVB.html

Scott Mitchell
A: 

You could convert the C# source code to VB.Net manually with this:

http://www.developerfusion.com/tools/convert/csharp-to-vb/

which will preserve comments. As far as automatically converting C# to VBA or VB6, I'd be willing to say that that is almost certainly going to be completely impossible. There are many aspects of C#/.Net that are not available in VBA or VB6 (like inheritance, for one).

MusiGenesis
+1  A: 

The best conversion seems to be done by SharpDevelop. Open your project and from the tools menu and select convert code to. Since it has all of your c# source code it does a very good job.

Aaron Fischer
+1 I have had good luck with using SharpDevelops built in conversion tool.
Element
Brilliant. Thanks!
RexE