0:00
Hi everyone, welcome to my fourth video on creating Excel add-ins
0:04
In my previous videos, I've used VBA and XML to create Excel add-ins
0:08
I've included the links to those videos in the description below. Today, I'll show you how to create a com add-in using C Sharp in Visual Studio
0:16
Although I'll be using C Sharp, you can also use Visual Basic if you prefer
0:21
It's up to you. First, download Visual Studio from the Microsoft website
0:26
The link is shown on the screen. If you already have Visual Studio installed
0:29
make sure you've installed the Office slash SharePoint development components. If not, download and run the Visual Studio installer
0:36
Check the Office slash SharePoint development box to install them. Open the Visual Studio, create a new project
0:43
choose Excel VSTO add-in option from the list, and click Next. In the next window, enter the project name BrainBell and click Create
0:51
Visual Studio will automatically generate the necessary files for the project. This add-in .cs is the main class for your add-in
0:58
and Visual Studio provides some initial code for this file. Go to the Solution Explorer on the right
1:03
If it is not visible, go to the top menu, choose View, and then click Solution Explorer
1:08
In the Solution Explorer, right-click on your project name and click Add
1:12
then choose New Item. Select Ribbon Visual Designer and click Add to insert it into your project
1:18
A new file, Ribbon1.cs, will appear where you can visually design tabs
1:23
groups, and buttons using the toolbox. Drag a tab and a group from the toolbox to the designer if they are not already inserted
1:30
Select the tab, go to the Properties, and set its label to BrainBellTab
1:34
Then select the group and set its label to BrainBell. Now select the BrainBell group in the designer
1:39
click Toolbox on the left to expand it, and drag a button into the group
1:43
While the button is selected, go to its properties, set the label to Toggle Gridlines
1:48
set Control Size to Ribbon Control Size Large, and go to the Image property to select an icon for the button
2:06
Next, double-click the button to edit its event handler code. Visual Studio will generate an event handler method for the button
2:13
Insert your own code into this method and remember to import the Excel namespace into this class
2:18
This code will execute when you click the Toggle Gridlines button in Excel
2:30
Now your project is ready for demonstration. Press F5 or click the Play icon below the top menu to build and run the project
2:37
Excel will open and the BrainBell add-in will be loaded. The BrainBell tab will appear before the Help tab
2:46
Try clicking Toggle Gridlines in the BrainBell tab and you'll see it working properly
2:50
Go to the Developer tab and click Comm Add-ins. You will see the BrainBell add-in listed and checked
2:56
Go to the Visual Basic Editor. Unlike VBA add-ins, you won't find any VBA code or add-in modules here
3:03
Close Excel and go back to Visual Studio. In the Solution Explorer, right-click on the BrainBell add-in project
3:12
and select Publish from the context menu. The Publish Wizard window will appear
3:16
Click Browse and choose an empty folder to save the add-in setup files
3:20
Once Visual Studio finishes copying the setup files, your add-in is ready
3:25
You can distribute it over a network, on a website, or install it on your own computer
3:29
Go to the add-in setup folder, run the setup file, and the add-in will install on your computer
3:45
You may need to enable it in the Developer tab's Comm Add-ins button
3:49
Thanks for watching. Please like, share, and subscribe for more videos