Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
Hi,
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 :
Jayanta.

Thanks In Advanced..
Posted

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.
 
Share this answer
 
Comments
JayantaChatterjee 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.
JayantaChatterjee 20-Jul-13 23:36pm    
Okay Sir.. :-(
Sergey Alexandrovich Kryukov 21-Jul-13 1:01am    
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.
—SA
Sergey Alexandrovich Kryukov 21-Jul-13 1:07am    
I just thought about the alternative. Please see my answer.
—SA
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:
http://en.wikipedia.org/wiki/OpenOffice.org[^],
http://www.openoffice.org/[^],
http://en.wikipedia.org/wiki/LibreOffice[^],
http://www.libreoffice.org/[^].

[EDIT #1]

You can use LibreOffice components in your C# application because there is such thing as LibreOffice SDK for CLI:
http://api.libreoffice.org/examples/examples.html[^],
http://api.libreoffice.org/examples/examples.html#CLI_examples[^].

[EDIT #2]

You can start with LibreOffice documentation on CLI binding:
http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/CLI_Language_Binding[^].

The LibreOffice binding assemblies you need to reference are listed here:
http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/Language_Binding_DLLs[^].

And so on…

—SA
 
Share this answer
 
v3
Comments
JayantaChatterjee 2-Aug-13 9:37am    
Sir, can I embedded OpenOffice in my Winform application??
Sergey Alexandrovich Kryukov 2-Aug-13 9:48am    
You can use LibreOffice SDK, please see the updated answer, after [EDIT].
—SA
JayantaChatterjee 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].
—SA
JayantaChatterjee 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... :-(
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.
 
Share this answer
 
Comments
JayantaChatterjee 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.
https://www.devexpress.com/Support/Center/Question/Details/Q532918

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900