Click here to Skip to main content
13,057,084 members (43,753 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I want to embed MS Word in my form.. So I searched and find this code :
Add a COM reference : Microsoft Office 12.0 Object Library
Then add the following namespace :
using Microsoft.Office;
using office = Microsoft.Office.Interop.Word;
And then in the code where you want to use, add this :
var wordApp = new office.Application();
Document document=wordApp.Documents.Open(//Specify the parameters)

But I don't find the Microsoft.Office.Interop.Word; the only class have in Office is Core...

I'm using .NET Framework 4.0;

How do I embed MS word in windows Form??

Regards :

Thanks In Advanced..
Posted 20-Jul-13 17:01pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I don't believe you can. The Interop libraries are meant to be used to interact with MS Office documents and to automate MS Word, but not to embed it. In order to use the libraries, you must have Office installed on the computer that the program is running on. In other words, its not a free MS Word ticket, Office has to be on your computer for the components to be installed in the GAC.
Jayanta Chatterjee 20-Jul-13 23:26pm
Sir I have MS Office installed on my computer...
is there any way to embed the MS word in winform ???
Ron Beyer 20-Jul-13 23:31pm
No, there is no visual component you can add in the interop libraries that embeds Word into a WinForm. The interop is only for you to generate word documents through code without a visual interface.
Jayanta Chatterjee 20-Jul-13 23:36pm
Okay Sir.. :-(
Agree, a 5.
I would add: there is an alternative way of using Word documents which does not require Office installation: Open XML API, but, quite obviously, it cannot be used to to embed Word.
I just thought about the alternative. Please see my answer.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

It looks like this is not possible due to one dominating factor: commercial character of Microsoft Office and its licensing.

That said, not only this is a problem which probably won't have a satisfactory solution, but you also should not try to approach it like that. You can look at the problem from a different perspective: you may need a non-Microsoft component capable of reading/writing some Office documents. And this looks more realistic.

The only open-source code I know is OpenOffice itself (where .odt came from) and its fork LibreOffice. Please see:[^],[^],[^],[^].

[EDIT #1]

You can use LibreOffice components in your C# application because there is such thing as LibreOffice SDK for CLI:[^],[^].

[EDIT #2]

You can start with LibreOffice documentation on CLI binding:[^].

The LibreOffice binding assemblies you need to reference are listed here:[^].

And so on…

Jayanta Chatterjee 2-Aug-13 9:37am
Sir, can I embedded OpenOffice in my Winform application??
You can use LibreOffice SDK, please see the updated answer, after [EDIT].
Jayanta Chatterjee 11-Aug-13 11:29am
Sir, I didn't understand there code. Can you please elaborate..
How I use Libreoffice in C#(which reference to be add), and how i embed the Openoffice text document in winform(On edit and printable mode)??????
Sergey Alexandrovich Kryukov 11-Aug-13 11:45am
Please see the updated answer, after [EDIT #2].
Jayanta Chatterjee 11-Aug-13 12:28pm
Sir,Can you give the code to embed openoffice text document in C# winform??
I read Your last updates and links also, but there's only the theory parts,they are telling which DLL files are required, but not telling how to implements... :-(
Sergey Alexandrovich Kryukov 11-Aug-13 12:50pm
Only the theory parts?! And then please ask yourself: are you a software developer of not?
Jayanta Chatterjee 12-Aug-13 10:06am
Sorry Sir,Its my mistake. I just read only documentations not the Examples...
now I got the Idea for implementation..
thanks ...
and My apology.....
Sergey Alexandrovich Kryukov 12-Aug-13 11:30am
No problem at all. So, will you accept the answer formally now (green button)?
Jayanta Chatterjee 21-Aug-13 9:19am
Sir,sorry for late reply.
I get an error that "the type or namespace name 'unoidl' could not be found(are you missing a using directive or an assembly reference?)" on this line : "using;".. :-(
I have installed "LibreOffice 4.1" and "OpenOffice 4.0.0" on my pc. I read about dlls,but I couldn't find DLLs(which start with cli in reference)..
Please Help .....
Look for LibreOffice API:
Member 11242856 28-Nov-14 7:29am
Sir, I can open already open the LibreOffice window. However, it opens separately from my winform. How can I display LibreOffice window in my winform?
Sergey Alexandrovich Kryukov 28-Nov-14 11:34am
What is that LibreOffice window. Probably you just created a separate LibreOffice process, not embedded the control.
Parenting a window in another windows is not a good idea (even though it's possible). Imagine the window in all the non-client areas in another window, also with non-client areas. The child window should be a control, to work normally. Well, you can remove non-client area, but the window could be designed to need it...
Member 11242856 1-Dec-14 19:19pm
Sir, please have a look at the sample output image of my Desktop application on this link:
The panel is where I plan to display the LibreOffice. I was able to embed pdf reader but its really hard to embed LibreOffice. The sample output image of the embedded pdf reader is in this link:
This is a good place to put a LibreOffice control, but not the application window. Maybe it's not so easy, but what can you do? Either do what you really need to, or what's "easy". :-)
Member 11242856 2-Dec-14 9:36am
Sir, can you give me ideas on how to do it? I don't quiet understand your first statement. Why can't I put the application window?
Well, in principle, you can, but application windows are not designed for that. In windows terminology, they are classified as "POPUP windows" and have all that non-client area controls you don't want...
misoles-g 2-Dec-14 18:17pm
So I have to embed LibreOffice control instead of the window. So how do I do it?
JCahyaatnttearjee 28-Nov-14 23:27pm
@member11242856 you can try this link:
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

There is no a free component as far as I know so your only option is to look for a 3rd party control. I know DevExpress has some kind of Rich Text Editor (I think they also provide one for WinForms) as well as Tx Text Control. And I bet there are some more out there.
Jayanta Chatterjee 21-Aug-13 9:23am
Can you please tell me how to use DevExpress Rich Text Editor in VB2010(C#) applications???
anorthwolf 23-Oct-13 23:57pm
DevX supports DOC/DOCX format file , but not support DOT/DOTX file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170728.6 | Last Updated 11 Aug 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100