Using WPF Custom Control Inside Word 2007 ActionsPane

Using WPF Control inside word 2007 is really simple today I'll walk you through the process.          

 

 

image 

 

1) Go to start ->Visual Studio 9.0->Microsoft Visual Studio codename Orcas.

2) select New project->Office->2007 and select Word Document and name it WPFControlforWord2007.

3) Add an Existing WPF Custom control library to the same solution.

4) Add the following References to WPFControlforWord2007

    1. PresentationCore
    2. PresentationFramework
    3. WindowsBase
    4. WindowsFormsIntigration
    5. CustomControlLibrary

5) Write following code to add the control in Action Pane

private

void ThisDocument_Startup(object sender, System.EventArgs e)

{

CustomControlLibrary.

RatingUserControl objwpfctr = new CustomControlLibrary.RatingUserControl();

ElementHost host = new ElementHost();

host.Height = 100;

host.Child = objwpfctr;

ActionsPane.Controls.Add(host);

}

Here it is we have Custom WPF control in Word 2007 Actionspane

image

Sample code is attached

WPFControlforWord2007.zip