Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
Hi this is my code:
        private void button1_Click(object sender, EventArgs e)
            String strFileName;
            //Find the Office document.
            openFileDialog1.FileName = "";
            strFileName = openFileDialog1.FileName;
            //If the user does not cancel, open the document.
            if (strFileName.Length != 0)
                Object refmissing = System.Reflection.Missing.Value;
                oDocument = null;
here i used webbrowser control for loading word document files.but this code not load a wordfile in my my document file displayed please tell how can i load word documents in my webbrowser control using c# windows application.
Posted 3-Aug-12 3:45am
Sergey Alexandrovich Kryukov at 3-Aug-12 14:09pm
Why? What requirements can justify such risky investment? --SA
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

To display a Word document you need to embed the Word OCX and read its documentation. Obviously, this requires that the user's machine has Word on it. A web browser, including the IE in the WebBrowser object, will typically start an external program to open this kind of document.
Sergey Alexandrovich Kryukov at 3-Aug-12 14:16pm
That's right (voted 5). That's why I recommended to consider different alternatives -- please see my answer. --SA
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Bad idea. Word is a proprietary product. Not only the customers will have to pay for the license, there would be a vendor lock-in ([^]) on the product, no compatibility, nothing good.
Think about: 1) HTML; 2) System.Windows.Forms.RichTextBox; 3) System.Windows.Controls.RichTextBox; 4) WPF Flow Document; 5) something else.
Please see:[^],[^],[^].
At the same time, Word file format compatibility is the easier problem. After all, OpenOffice, LibreOffice and other products support all versions of the format, please see:[^],[^].
If you would like to support only the newer Office Open XML, the format itself is available and is standardized under ECMA-376 and ISO/IEC 29500:2008:[^],[^].
Please see the comparison chart on Office Open XML software:[^].
As some source code is available and open, you can use it.
Kenneth Haugland at 3-Aug-12 14:19pm
Very good. 5.
Sergey Alexandrovich Kryukov at 3-Aug-12 14:24pm
Thank you, Kenneth. By the way, just updated with a big [EDIT] on Office Open XML. --SA
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Refer the link for similar discussion:
How to display word file in dot net windows application using web browser control[^]



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

  Print Answers RSS
Your Filters
0 Shai Vashdi 1,518
1 OriginalGriff 503
2 Manas Bhardwaj 393
3 Tadit Dash 310
4 Damith Weerasinghe 290
0 Sergey Alexandrovich Kryukov 9,575
1 OriginalGriff 5,856
2 Peter Leow 4,405
3 Maciej Los 3,540
4 Abhinav S 3,513

Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 7 Sep 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid