VBA v C# Performance

499 views
Skip to first unread message

jj554

unread,
Oct 13, 2014, 7:29:56 PM10/13/14
to exce...@googlegroups.com
Hi

I recently stumbled upon Excel-DNA and am eager to dig in. I've been writing in VBA extensively over the past year but I am becoming increasingly familiar with C# and have run into some problems that could be solved with an OO language. First of all, from what I've read, the integration is mainly used for more efficient UDF's. I have a large workbook that is fed by DDE links and is mainly driven by events and coded in VBA rather than worksheet functions. Would recoding everything in C# provide faster performance on simple to moderately complex methods that control the acquisition and processing of data? I guess I'm trying to understand where the performance enhancement makes the most difference.

Also, I've always had a difficult time capturing the changes of DDE links. Does anyone know if this could be accomplished using .NET? 

Thanks for the feedback.

Govert van Drimmelen

unread,
Oct 14, 2014, 1:54:33 AM10/14/14
to <exceldna@googlegroups.com>
Hi Jesse,

It's hard to general statements about the performance of .NET code vs. VBA. In general you should see good improvement for processing that happens only inside your code. For code that mainly automated Excel through the COM object model, .NET won't be faster.

You might also consider another option - using VB.NET as an alternative to C#, or an intermediate step along the way. With some care, the VBA can be written or changed so that it's easy to port, and you get all the benefits of .NET and the OO features.

About the DDE part I don't know much.

-Govert


--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at http://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Ron

unread,
Oct 14, 2014, 9:10:49 AM10/14/14
to exce...@googlegroups.com
Hi,

My add-in does also have some DDE features (client only - to read data from Excel or other apps), so yes this can be accomplished using .Net. But DDE really is a headache !
You can always use the Excel native api to perform the DDE request, it works fine, but you will always have to do it in the Excel main thread if you don't want Excel to crash (this is still COM). 
If you want to do some parallel load using DDE, then you will need another tool. On my side I found NDde which works well. Unfortunately, the version I got does only carry raw strings, which is fine if you requests Excel. But some old applications might use a custom "DDE" format, which I had a lot of difficulties to parse but I managed to do it. I can give you more details on that part if you want to.

Regards,
Ron
Reply all
Reply to author
Forward
0 new messages