VBA VS. VSTO what is the difference, should I upgrade?

前端 未结 4 1076
太阳男子
太阳男子 2021-02-07 01:00

I am a huge fan of the KISS principle (Keep it simple) and a long time VBA for excel user. However all the articles I can find on VBA vs. VSTO (Visual Studio Tools for Office) s

4条回答
  •  渐次进展
    2021-02-07 01:16

    This is 6 years after this question was originally asked so it's possible that at the time of the OP a comparison between these two tools were different, but I am actually very surprised at how favorable the existing answers are towards VBA!

    VBA is interpreted and housed entirely within the application. The advantages here are:

    • Coding can be done directly within the application, requiring no external tools
    • Application-specific features like Macro recording can enable quick prototyping
    • You can leverage Excel-specific ActiveX controls like RefEdit
    • UDFs can be developed easily
    • AddIns are distributed as documents (.xla format)

    For small applications and UDFs VBA works fine. You can build quickly and easily in Excel and things "just work."

    If your program has any type of complexity however, it would be very worthwhile to explore VSTO. Advantages there include:

    • Ability to use multi-paradigm programming languages like VB.NET or C#
    • Better collection support (generic lists, dictionaries, tuples, etc...)
    • Support for threads, asynchronous execution
    • Deployment of AddIns as standalone applications
    • Ability to use native WinForms and develop non-blocking UIs

    VSTO is at this point is pretty well documented:

    https://docs.microsoft.com/en-us/visualstudio/vsto/create-vsto-add-ins-for-office-by-using-visual-studio

    The topic of performance is rather vague but to contrast some of the previous answers this really depends on your bottlenecks. COM interoperability may add overhead, but at the same time the VBA execution model is much slower than what can be offered by C#. Particularly when you take into account the various paradigms that programming a VSTO can offer three are applications where a VSTO will be orders of magnitude faster than a similarly coded VBA program.

提交回复
热议问题