VSTO Development Overview

Source: Internet
Author: User

VSTO Development Overview

Liu Yongfu


This article introduces you to the basics of getting started with using Visual Studio programming tools to develop Office plug-ins.

VSTO is the short name of visual Studio Tools for Office, Visual Studio is the most sophisticated programming suite developed by Microsoft, including C#,VB. NET and more, because of the power and convenience of the VS feature, and Microsoft is constantly updating it, using VS to develop office is a necessary trend.

Part I: VSTO development environment configuration

This section talks about what you need to do to develop VSTO. From a large aspect, you need developer + OS + Office + Visual Studio, these four aspects.

That is, people who need to be programmed need to install Office and Visual Studio on the appropriate operating system.

1.1 Requirements for Developers

For VSTO development, you have the basics of programming and are skilled in office operations, preferably with the foundation of VBA programming.

1.2 Choice of operating system

Either Windows XP or Win7 (32bit) can be developed in VSTO.

1.3 Installation of Office

The most common version of Office is 2003 2007 2010 2013, and so on, depending on the needs of the developer or the user, the biggest difference is that the advanced version of the interface is in the functional area rather than the traditional toolbar form. Therefore, it is important to note this difference for VSTO development.

1.4 Installation of Visual Studio

Visual Studio has a common version of VS2005 2008 2010 2013 2015 and so on, if you want to do VSTO development, in the process of installing VS, be careful to check the "Install VSTO" option. If unchecked, Then you can only use VS for regular form development or class library development, which is fine with office.

Which version of Visual Studio is appropriate to install, which is very much related to the operating system and Office version, if your operating system is XP, then vs can only install 2010 and the following version, and VS2012 and above need to install on Win7 above.

On the other hand, you need to know exactly which version of Office you want to develop, in general, the higher the version of Office, the higher the required VS version, and see the diagram below.


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7D/34/wKiom1biUzmhigPLAAYBd_ntB28831.jpg "title=" The VSTO version corresponds to the figure. jpg "alt=" wkiom1biuzmhigplaaybd_ntb28831.jpg "/>



As can be seen, if you want to develop for Office2003, use vs2005/2008 more appropriate, if for Office2010 development, use vs2010/2012 more appropriate.

Here, I give two sets of optimal development portfolio:

(i) XP or Win7 + Office 2003 +vs, this solution is intended for traditional users.

(ii) XP + office + VS, this scenario is intended for users who are accustomed to the advanced version of Office.

or Win7 + Office + VS.

1.5 Developing language Settings

There are two languages available for VSTO development, Visual C # or Visual Basic, which you can choose to install during VS installation. You can also select a language when you create a VSTO project.


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7D/33/wKioL1biU_OjMZoiAALCyR1a_AU800.jpg "title=" VS2008 Create Excel2003 Add-in. jpg "alt=" wkiol1biu_ojmzoiaalcyr1a_au800.jpg "/>


As shown above, the VS2008 is used to create a new VSTO project using the language of the visual C#,office version is 2003

Part II: VSTO Development type

In general, VSTO can develop Office add-ins (add-ons), as well as document-level development.

2.1 Office Add-ins

As the name implies, an add-in is a COM add-in that targets the Office application level and is scoped to the application, not to a document. We know that any program has an entry point, such as we do Windows Forms development, the general program is from the form of the Load event to go in, Thus loading other parts, if there is no form, is generally run from the main function.

For VSTO add-ins, his entry function is ThisAddIn_Startup, which is an event procedure, which means that when the COM is loaded in office, the function is run first. When the compilation succeeds, The corresponding DLL file is generated in the Debug folder of the project folder, and some other related files are the final works of VSTO.

2.2 Office Document-level development

Next talk about document-level development, this development is for a single document, such as when we created the project, we chose Excel workbook, then everything you do is done around this workbook, and other documents have nothing to do. The last created work, This is the workbook and the DLL files associated with it.

As for what you want to do with office in VSTO, it's about the specific requirements, how to write the code in Visual C # or vb.net, which requires you to learn C # syntax and learn how to use C # Knowledge of operating and controlling Office components. If you have experience with VBA, it's not too difficult to learn this.

In addition, the biggest difference between a VSTO project and a regular C # form application or console program is that the external references required for VSTO are automatically added when the project is created.

Part III: Introduction to VSTO Interface development

In fact, the simplest VSTO program, after manually creating an Excel Add-in project, writes in the auto-generated ThisAddIn_Startup event procedure:

private void ThisAddIn_Startup (object sender, System.EventArgs e)

{

MessageBox.Show ("VSTO, I'm Coming");

}


Don't do anything else. Press F5 test directly, this is a complete VSTO program.

In fact, VSTO can also design an interface for office, from a large category to the following:

3.1 Modifying the Office toolbar

This design is for the Office2003 version, generally in the VSTO startup event process, the CommandBars object to operate, which is very similar to VBA.


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7D/33/wKioL1biVCeTnXZlAAN01100aPc756.jpg "title=" Create Excel2003 add-ons in VS2008-toolbars. jpg "alt=" wkiol1bivcetnxzlaan01100apc756.jpg "/>


3.2 Functional Area Customization

This design is for Office2007 and above, and can customize the Ribbon's XML in VSTO, and when the user taps a button in the Ribbon, it responds to the related procedure function in VSTO. This part of the development, need to master customui knowledge.

3.3 Adding task panes to Office

One of the important concepts of VSTO development is that C # forms and controls can be used in office, and of course, with the knowledge above, it's easy to render a C # form in office when the VSTO add-in loads, simply by is to add a form to the project, and then show the form in the startup event of the add-in. Unfortunately, this form and Excel do not look as one, and it is inconvenient to use it. To do this, we can introduce the task pane to Office (Custom task Pane, CTP). Developers can add some user controls (UserControl) to render them in the Office interface.


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7D/33/wKioL1biVfbT867BAAjassNz-RM021.jpg "title=" Excelobject_vsto_vba.jpg "alt=" Wkiol1bivfbt867baajassnz-rm021.jpg "/>


3.4 Document Actions Pane

If you want to customize a pane for a document, you must create a VSTO project of the document type, not an add-in. However, this pane is not called the task pane, but is called the Document Actions pane (ActionsPane). The parent of this object is ThisWorkbook or ThisDocument , not ThisAddIn.


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7D/33/wKioL1biVnDzsQMpAASAkRkQX9g798.jpg "title=" Create Excel2003 workbook in VS2008-Document actions pane. jpg "alt=" wkiol1bivndzsqmpaasakrkqx9g798.jpg "/>


Part IV: Other Related Topics


4.1 Developing Excel Custom Functions (UDFs) using C #


4.2 How to handle an application or document event in VSTO


4.3 How to use C # forms and controls


4.4 Management of C # project references, use of external objects


...... For more information please follow my course, our VSTO development group is ryueifu_vba:61840693.


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7D/35/wKiom1biV2rgoj-xAATBvRyHtT4725.jpg "title=" Worddocumentmap.jpg "alt=" Wkiom1biv2rgoj-xaatbvryhtt4725.jpg "/>




This article is from the "Vba_expert" blog, make sure to keep this source http://ryueifu.blog.51cto.com/6673733/1749914

VSTO Development Overview

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.