I don't know much about .net, but I am working on a project where a requirement is to port some Excel VBA code embedded in spreadsheets to standalone C# .
Are they any tools that could automate (or semi-automate) this port or compile? How well do they work?
No. Your best bet, if it's not alot of code is to do it by hand.
Otherwise, you mileage might vary. You might try converting the VBA to VB.NET and then use a tool to convert that to C#.
Converting Code from VBA to Visual Basic .NET
Ten Code Conversions for VBA, Visual Basic .NET, and C#
This is an old thread, but thought I would complete it as I :
If you need to convert your code to C# use Telerik's web code converter: http://converter.telerik.com/. Simply paste your VBA code (make sure you are not using Excel specific functions or variables like Range, Worksheets etc.) and convert. You should be able to easily re-use the code in your C#.NET project in Visual Studio.
If you want to make the library re-usable in Excel (make it COM-visible) check-out this post here.
If you don't need to make the DLL COM-visible simply create a VB.NET project in Visual Studio, compile and fix any found compilation errors :).
Otherwise, if want the DLL to be automated directly from Excel - I recently created an Add-In that does just that. It creates a COM-visible DLL directly from your Workbook (just select your VBA Functions) and pastes the required load procedures into your workbook as well. Find it here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With