HTML5 and CSS3 enabled 3D web experience at roomsay.com:

RoomSay.com 3D Web Experience RoomSay.com 3D Web Experience DIY

Vectorlight News

  • 3D CSS used to Create Website
    Feb 08, 2014

    With the CSS 3D effects being implemented in modern browsers RoomSay.com takes this new technology and enables you to map your traditional 2D content onto the walls of a 3D room.

  • Chat App Converted to HTML and JQuery
    Sep 08, 2011

    Converted from Silverlight to HTML and Javascript/JQuery is the Vectorlight Chat App. Login using your Vectorlight password to chat using your username and avatar.

  • HTML5 iPhone,Android Big Guns Tower Defense
    Jul 02, 2011

    Big Guns has made the leap from Windows Phone 7 (XNA) to HTML5 so you can now play it on your iPhone, Android and other HTML5 compatible devices.

  • HTML5 Games - Word Poppers and Batty
    Jun 04, 2011

    As the take-up of HTML5 quickens (74% of users currently have a browser capable of HTML5 Canvas) we present two more games for both your browser and mobile.

  • Big Guns Tower Defense on Windows Phone 7
    May 06, 2011

    Coming soon to Windows Phone 7 is an XNA port of the popular Vectorlight tower defense game Super Tower Defense. Whilst retaining many of the graphical and gameplay features of the original Silverlight game.

  • Home Page News

Communicating with MS Word

When a Silverlight 4 application is running with Elevated Permissions you can access COM objects which can be quite handy.  Here we have a small example showing how to open Word and set some text.

Word and Silverlight

It is important to include the following namespace when wanting to use these features:

using System.Windows.Interop;

You will also need to add a reference to the Microsoft.CSharp.dll which can be found in:

Program Files/Microsoft SDKs/Silverlight/V4.0/Libraries/Client/

<UserControl x:Class="SilverlightWord.MainPage"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Button Content="Open MS Word" Width="100" Height="30" Click="Button_Click" />

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Interop;
using System.Runtime.InteropServices.Automation;

namespace SilverlightWord
    public partial class MainPage : UserControl
        public MainPage()

        private void Button_Click(object sender, RoutedEventArgs e)
            dynamic word = AutomationFactory.CreateObject("Word.Application");
            word.Visible = true;

            dynamic doc = word.Documents.Add();
            string insertText = "Hello Word from Silverlight 4!";
            dynamic range = doc.Range(0, 0);
            range.Text = insertText;

Like the Excel example we are using the new dynamic keyword present in C# 4, this allows us to grab an instance of the Word application.  To open Word and display it we use:

word.Visible = true;

We then create a new Word document and add some text, there is a whole host of possibilities with the new COM access capabilities of Silverlight 4.

Your Comments

michael posted

Dear author:

I do as you tell above, but the program(sliverlight project) don't work ,the error message is as following :

Could you tell me what  the proble is ?


User code untreated System.NotSupportedException

   Message = The operation is not supported in the current context.


        Located MS.Internal.Error.MarshalXresultAsException (UInt32 hr, COMExceptionBehavior comExceptionBehavior)

        Located MS.Internal.XcpImports.CheckHResult (UInt32 hr)

        Located MS.Internal.ComAutomation.ComAutomationNative.CreateObject (String progID, IntPtr & nativeObject)

        Located MS.Internal.ComAutomation.ComAutomationServices.CreateObject (String progID, ComAutomationParamWrapService paramWrapService)

        Located System.Runtime.InteropServices.Automation.AutomationFactory.CreateObject (String progID)

        Located TCMS.Client.PrintTemplateManageControl.btnPreview_Click (Object sender, RoutedEventArgs e)

        Located System.Windows.Controls.Primitives.ButtonBase.OnClick ()

        Located System.Windows.Controls.Button.OnClick ()

        Located System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp (MouseButtonEventArgs e)

        Located System.Windows.Controls.Control.OnMouseLeftButtonUp (Control ctrl, EventArgs e)

        Located MS.Internal.JoltHelper.FireEvent (IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)



michael posted

what 's the problem?,the error is as following :


用户代码未处理 System.NotSupportedException



       位于 MS.Internal.Error.MarshalXresultAsException(UInt32 hr, COMExceptionBehavior comExceptionBehavior)

       位于 MS.Internal.XcpImports.CheckHResult(UInt32 hr)

       位于 MS.Internal.ComAutomation.ComAutomationNative.CreateObject(String progID, IntPtr& nativeObject)

       位于 MS.Internal.ComAutomation.ComAutomationServices.CreateObject(String progID, ComAutomationParamWrapService paramWrapService)

       位于 System.Runtime.InteropServices.Automation.AutomationFactory.CreateObject(String progID)

       位于 TCMS.Client.PrintTemplateManageControl.btnPreview_Click(Object sender, RoutedEventArgs e)

       位于 System.Windows.Controls.Primitives.ButtonBase.OnClick()

       位于 System.Windows.Controls.Button.OnClick()

       位于 System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)

       位于 System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)

       位于 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)


xyz posted

When I tried executing the above code, I am getting a exception call "NOT SUPPORTED EXCEPTION"

Mark Kamoski posted

Dear Author -

Please help.

Do you know how to input and output Word documents to and from Silverlight?

As your excellent example shows, it is possible to launch Word from a Silverlight application.

However, what I want to do is to be able to import and export Word documents to and from a Silverlight application

I could use DOC format or ODF format or RTF format or some other document format, as long as the document format supports full editing in Silverlight, with embedded images in the document.

How can that goal be achieved?

Please advise.

Thank you.

- Mark Kamoski

Badam Santhosh posted

When I tried executing the above code, I am getting a exception call "NOT SUPPORTED EXCEPTION".

Please help me out.

Zhao posted

I cann't find the namespace of "using System.Runtime.InteropServices.Automation;"

How to get?

sajen posted

how can i add an image to word?

balu posted

is it possible to save the contents of a textbox as .doc file



spam-dev posted

can i use in silverlight without OOB.


h posted

how to set the word table style?

such as "oTable.Borders.OutsideLineStyle =  Word.WdLineStyle.wdLineStyleSingle;

there is no Word.WdLineStyle.wdLineStyleSingle

DavidH posted

Do you think you would be able to do the same thing with a fillable PDF form?

dan posted

Hi Vlad & lsym1985,

Yest, you must be running in OOB and have Elevated Permissions to use COM.


vlad posted


This feature is available only in OOB mode?



lsym1985 posted

how I can access MSWordCOM,I have no Permission


Post your Comments

Rate this: 

1 Star 2 Star 3 Star 4 Star 5 Star
23 Ratings / 3.9 Average


Silverlight Controls

  • Rich TextBox

    Create and edit rich content with this slick and expandable Rich TextBox...

  • TreeView

    This easy to use TreeView comes with drag and drop, sorting, searching and much more...

  • Context Menu

    You too can have cool popup context menus in your Silverlight applications...

  • Resizable Dialog

    Draggable and resizable popup dialogs are what serious Silverlight developers need...

  • Spell Checker

    Real-time spell checking in Silverlight? We did it first here...