In the previous blog post we described how to add an ActiveX component (control) to a Visual Basic 2010 project. In this blog post we will describe how to insert an ActiveX component in an Excel sheet. We will show the necessary steps to include an ActiveX component in a sheet in Microsoft Excel 2010. We will use the same calendar component as in the previous blog post in this step-by-step example (we will use the one month calendar from SamLogic Calendar Components).
How to add an ActiveX component to an Excel 2010 sheet
1. Start Microsoft Excel 2010.
2. First make sure that the Developer tab is visible in the Ribbon interface. If not, follow the steps (A-E) below:
A. Open the File tab in the Ribbon.
B. Select Options.
C. Choose Customize Ribbon.
D. Check the Developer checkbox.
E. Close the Excel Options dialog box. The Developer tab in the Ribbon interface should now be visible.
3. Open the Developer tab.
4. Click on the Insert Controls option.
5. Click on the More Controls option in the ActiveX Controls group.
6. From the control list in the More Controls dialog box, choose the SamLogic SLXCal Control control and press the OK button.
7. A cross-like cursor will now appear. Click somewhere in the sheet to specify the calendar component’s position in the sheet.
The calendar component should now appear in the sheet as shown in the picture above.
That’s all steps that we need. We have now added an ActiveX component to an Excel sheet!
The calendar component is event driven, so if you want to open up an event handler for the calendar you can double-click on the calendar component. The DateChanged event handler will now be shown in a code window.
If you click on the dropdown list in the upper right of the code editor you can choose another event handler, for example the DateSelected event handler. The DateChanged event is fired when a user changes month in the calendar and the DateSelected event is fired when a user clicks on a date (day number) in the calendar.
You can set some properties for the calendar component before it is used. If you switch back to the Excel sheet with the calendar and right-click on the calendar and choose the Properties menu item in the local menu that is shown, you will find a list with properties for the calendar component. If you want to set any properties before any code is executed you can set them here.
After the execution of the code has started, you can change properties for the calendar component programmatically.
More information about the one month calendar component
More detailed information about the one month calendar component in SamLogic Calendar Components, including a complete list of all properties, events and methods in the component, is available on this web page:
> One-Month Calendar Component (ActiveX)
In the next blog post
In the next blog post we will show how to install an ActiveX component in a Windows system. Just copying an ActiveX component to a computer’s hard disk is not enough; no, it needs also to be registered in the system. And it is important that the component is installed in the correct folder on the hard disk, otherwise a software using the component may get problem finding the component. In the next blog post we will describe the process of installing an ActiveX component in a Windows system closer.