The common way to develop new functionality or custom functionality to outlook, word, excel is to develop COM addins. There are many different different technologies for making these types of addins such as Visual Basic 6.0, Delphi, C++ and .net etc.
If we talk about .NET Then there are two main ways for develop addin:
(a) With thew help of IDTExtensibility interface and other
(b) With the help VSTO(Visual studio tools for office) technology.
VSTO supports both languages VB.net and C# and office 2003 and later version.
this article demonstrate that how to make wordaddin for word 2010 by using vsto 2010.
Objective:
Showing Welcome message on word application start up
Start project:
Start vsto project File — > New project — > installed Template — > Visual C# — > office — > 2010
Select Word 2010 add-in
Visual studio automatically generate thisAddin.vb class( thisaddin.vb in vb.net and thisaddin.cs in C#.). we can see this class in our project. We can use this class to perform various task such as customizing the user interface of the word application , accessing object model of office host application(ih this project microsoft is the host application) etc. this type of addin is also called by ‘application label addin’.
There are two default event handlers in this class one is ThisAddin_Startup and other is ThisAddin_ShutDown.
Vsto addin use object model of host application, means if we are working for outlook addin in vsto then addin will use outlook object model or if we are working in word addin project then addin application will use word object model so our addin application will use Word Object Model.
So right now I am telling about some important things about word object model
Word object model consists of classes and interfaces that are provided in the primary interop assembly for Word, and are defined in the Microsoft,office,Interop.Word namespace.
The following sections briefly describe the top-level objects of word object model and how they interact with each other. These objects include the following five:
- Application object
- Document object
- Selection object
- Range object
- Bookmark object
Application Object
The Application object represents the Word application, and it is root object of other objects. We can use its properties and methods to control the Word application.
Document Object
Document object represents a document and all of its contents. When you open a document or create a new document, you create a new Microsoft,office,Interop.Word.document object, which is added to the Documents collection of the Application object. The document that has the focus is called the active document. It is represented by the ActiveDocument property of the Application object.
Selection Object
The Selection object represents the current selected area. When you perform an operation in the Word user interface, such as bolding text, you select, or highlight the text and then apply the formatting
Range Object
The Range object represents a contiguous area in a document, and is defined by a starting character position and an ending character position.
Content Control Objects
A Microsoft,office,Interop.Word.ContentControl provides a way for you to control the input and presentation of text and other types of content in Word documents. Such as richtext contentcontrol,plaintext content control…
And Now edit the ThisAddIn class for showing welcome message on the add in start up routine.
Code:
public partial class ThisAddIn { Private void ThisAddIn_Startup(object sender, System.EventArgs e) { MessageBox.Show("Welcome to My Word Add-in"); } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { } }
Run Addin:
Download attached project and build project
Hi again
By your articles it looks u have done alot of research on Office Addins.
Do you have any idea about how to make an addin of Office One Note 2010.
Hi,
can we show a custom dialog box on save click where dialog box will have a drop down list from which user have to chose one item and then press OK button and on the OK click it will show the Save dialog box.