Click here to Skip to main content
12,957,071 members (62,813 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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
   
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
   
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 3-Aug-12 14:19pm
   
Very good. 5.
   
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
Top Experts
Last 24hrsThis month
OriginalGriff 6,924
CHill60 3,550
Maciej Los 3,312
ppolymorphe 2,120
Jochen Arndt 1,973


Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 7 Sep 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