Click here to Skip to main content
11,636,598 members (73,539 online)
Rate this: bad
good
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 = "";
            openFileDialog1.ShowDialog();
            strFileName = openFileDialog1.FileName;
 
            //If the user does not cancel, open the document.
            if (strFileName.Length != 0)
            {
                Object refmissing = System.Reflection.Missing.Value;
                oDocument = null;
                webBrowser1.Navigate(strFileName);
            }
        }

here i used webbrowser control for loading word document files.but this code not load a wordfile in my application...here my document file displayed separately..so please tell how can i load word documents in my webbrowser control using c# windows application.
Posted 3-Aug-12 3:45am
Comments
Sergey Alexandrovich Kryukov at 3-Aug-12 14:09pm
   
Why? What requirements can justify such risky investment?
--SA
Rate this: bad
good
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.
  Permalink  
Comments
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
good
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 (http://en.wikipedia.org/wiki/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:
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.aspx[^],
http://msdn.microsoft.com/en-us/library/aa970909.aspx[^].

[EDIT]

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:
http://en.wikipedia.org/wiki/OpenOffice.org[^],
http://en.wikipedia.org/wiki/LibreOffice[^].

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:
http://en.wikipedia.org/wiki/Office_Open_XML[^],
http://en.wikipedia.org/wiki/Office_Open_XML_software[^].

Please see the comparison chart on Office Open XML software:
http://en.wikipedia.org/wiki/Comparison_of_Office_Open_XML_software[^].

As some source code is available and open, you can use it.

—SA
  Permalink  
v5
Comments
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
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  

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

  Print Answers RSS
0 jyo.net 295
1 Sergey Alexandrovich Kryukov 275
2 OriginalGriff 233
3 Suvendu Shekhar Giri 225
4 stibee 215
0 OriginalGriff 8,941
1 Sergey Alexandrovich Kryukov 8,459
2 Mika Wendelius 6,849
3 F-ES Sitecore 2,364
4 Suvendu Shekhar Giri 2,320


Advertise | Privacy | Mobile
Web03 | 2.8.150728.1 | Last Updated 7 Sep 2013
Copyright © CodeProject, 1999-2015
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