In this installment of Roll Your own Analysis Office Features, we’ll compare the two main options for building applications in MS Excel (and by extension, Analysis Office) and their relative advantages and disadvantages. Both allow you to enhance MS Office and provide access to its object model. With both, you can also access the Analysis Office VBA API to retrieve information from data sources, manipulate them or execute planning sequences/functions.
This is the classic “macro” scripting language for MS Office. If you have ever written a macro for MS Office, or even used the record macro function, you have created a VBA script. Aside from being based on a long obsolete programming language (VB6), it offers the advantage of being simple and easy to learn. It is also ubiquitous on the MS Office platform, only being missing from Office 2008 on the Mac. Its main use case is writing scripts from within MS Office. VBA macros reside inside the Workbook as content and are shared as an integral part of the workbook.
VSTO is a .NET framework for automating and extending MS Office applications by creating plugins. It gives the developer access to more modern and powerful programming languages, such as VB .NET (a more modern variant if Visual Basic) and Miscrsoft’s flagship programming language, C#. There are three basic approaches to VSTO extensions. They can be a plugin, which is always loaded when Excel is started, they can be a plugin which is loaded when a specific document is opened, or they can be a plugin that is loaded when a specific template is used.
This depends of course. If your code is small, you can execute it by responding to an event (either a standard MS Excel event, or Analysis Office's CallbackAfterRedisplay event) and there is a single or limited number of points of access (i.e. there are not many copies of the workbook floating around), then VBA is the right approach. If you are dependent on CallbackAfterRedisplay , then you should use VBA in any case. For example, we could have taken the FocusAutoRefresh macro from the last installment and wrapped it into Excel's Worksheet.Change event to automate the focusing of the auto refresh rules.
If your code is large and ambitious, VBA may become unwieldy and you might want to consider a VSTO language. If you can't simply silently react on events and have to add a UI component, you should also consider VSTO. This will give you the tools that you need to make a refined UI, including your own ribbon. The techniques of yesteryear - in-sheet buttons, Active-x controls and macros from the macro list - will be regarded as hackish and barbaric by today's users. Lastly, if you need to centrally maintain a distributed network of workbooks, VSTO is the right choice.
Next time, we'll build a simple VSTO app which includes a custom ribbon.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
38 | |
25 | |
17 | |
13 | |
7 | |
7 | |
7 | |
7 | |
6 | |
6 |