On the development of Excel (vii) custom task forms for Excel

Source: Internet
Author: User
Tags object model visual studio

Related articles:

On Excel Development (1) Overview of Excel Development

On Excel Development (II.) Excel menu system

On the development of Excel (III.) Excel object model

I spent three articles on the UDF functions in Excel, the RTD function, and the asynchronous UDF functions, which are the most important in Excel development. This article begins with the second article's menu system to begin to explain the interface elements that Excel can develop, and this article is about the custom task Panel in Excel (custome task PANEL,CTP).

The custom task pane was introduced in Office 2003, and I'm sure you've all used dictionaries in Word and inserted clip art, and the sidebar on the left is a custom panel. The following figure:

But the custom panel for Office 2003 doesn't give us developers the development interface, which means we can't create our custom task pane.

Starting with Office 2007, one notable change in office is the addition of more quick previews and custom dashboards, which are reflected in every product in office. The following figure:

More importantly, starting with Office 2007, the CTP interface enables developers to integrate our own business logic into custom dashboards.

Advantages of a custom task panel

The custom parameters panel has some advantages:

First: Compared to the traditional modal and modeless pop-up boxes, the CTP is embedded in office, so that our interaction on the CTP and the content of the workspace do not disturb each other, do not distract people's attention:

Second: The user's learning cost is lower, user-defined task panel and built-in panel behavior similar, these panels can also be in the program inside and around dock or suspension, we can create multiple task panels, and each panel for separate control.

Again, on the development side, the CTP in Visual Studio actually with the form controls, we can directly create a user-defined control, and then, in the design panel like the design of a Windows Form program to set.

The working principle of the second CTP

Interfaces exposed through the extensibility COM class Library of Office can create CTP forms. The CTP is actually a form that contains an ActiveX control, and Excel manages the CTP forms, including how to create, destroy, and handle messaging between forms, while ActiveX controls provide our business logic capabilities. The CTP is a container that he can combine well with Excel. CTP forms can be docked or suspended in the Excel interface, and users can resize, move, or close them, which are handled by Excel.

In general, we can create CTP applications in VSTO and Sharedaddin. Using VSTO to create a CTP application is easier, just create a custom form. Creating a CTP application in Sharedaddin is a bit more complicated, and Excel needs to create a CTP form when loading AddIn, the whole process is as follows:

First, when Excel starts, the specific AddIn program is loaded by a registry entry, and when the addin is loaded, the query addin is implemented by the Icustomtaskpane interface, if so, the CTPFactoryAvailable interface is invoked, and save the parameter ICTPFactory object of the method, and then call the object creation method to create the object, the Create method needs to specify the ProgID value of the ActiveX control inside the CTP window, and then save the resulting CustomTaskPane object , displaying or hiding the object based on the menu item.

Next, how to implement the CTP function in VSTO and Sharedaddin.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.