Now that we've discussed the pros and cons of using VSTO versus VBA, let’s try our hand at creating a very simple app in VSTO. We have a query consisting of sales figures, where one of the available dimensions is the “sold-to party country”. We are presuming here, that we want a dashboard style app with a simplified interface and the Analysis ribbon might even be hidden entirely. Rather than using the usual Analysis filtering methodologies, we’ll create a new ribbon, allowing the user to filter by country simply by selecting the flag of the chosen country in the ribbon as shown in the video:
Since this tutorial is a bit long for a single blog post, we'll build the layout this time and next time we'll add the code to make it work.
To build this, we need the following:
First, create a new workbook and add your data source. Then close it. Open Visual Studio and create a new Excel Workbook project. You can also create a template or general Excel plugin, but I’d recommend against it. We want to confine our app to a single workbook and don’t need an otherwise unnecessary plugin hanging around.
When prompted to create a new workbook, or to copy an existing workbook, select the latter and import the workbook that you just created.
After your workbook project has been created, add a new ribbon to it. Go to the Solution Explorer pane. Right click on the project root, select “Add” from the context menu and select new Item. Select “Ribbon (Visual Designer)”.
Feel free to use the properties pane (shown on the left) to rename your ribbon and group.
From the Toolbox tab, drag five ToggleButtons to your filter group in the custom ribbon. We’re using five, because our data source has five countries.
For each of the buttons, you should:
As a recommendation, the name of the button should be set to something which helps you remember which button is which, when working inside the C# code later on. E.g. instead of toggleButton1 to toggleButton5, you could use toggleButtonAU, etc.
When you are finished massaging the ribbon buttons’ properties, your ribbon should look like this in Visual Studio.
Now we have the graphical layout of our app. Next time, we’ll work on wiring up the events to make the buttons actually work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
10 | |
9 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 | |
4 |