Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Dear All,


Am new in development section and need to show the word file in VS2008 and how m able to shoe the word file i have used the following code plz provide me the needfull

using Word = Microsoft.Office.Interop.Word;
.
.

public partial class SE_SEIT_PSOOP_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
object missing = System.Reflection.Missing.Value;
object readOnly = false;
object isVisible = true;
object fileName = "~/SE/SEIT/DSF/E-notes/UNIT I I.docx";
Microsoft.Office.Interop.Word.ApplicationClass applicationWord = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word.Document modelloBusta = new Microsoft.Office.Interop.Word.Document();

try
{

modelloBusta = applicationWord.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
modelloBusta.Activate();



}
catch (Exception eccezione)
{
Console.Write(eccezione);
modelloBusta.Application.Quit(ref missing, ref missing, ref missing);

}
}
}
Posted

1 solution

Microsoft warns against the use of Office Interop in server settings:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2[^],
http://support.microsoft.com/kb/257757/en-us[^].

Basically, you need to map some office documents to HTML and show it.

If you only want to work with some office documents, you can use Open XML SDK:
http://www.microsoft.com/en-us/download/details.aspx?id=30425[^].

This way, you can support new XML-based Office formats (such as .DOCX, .XLSX), ECMA-376 standard:
http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^],
http://en.wikipedia.org/wiki/Office_Open_XML[^].

This way, you can work without Office installed. Also, the documents are supported by 3rd-party software. Please see my past answers:
Convert Office-Documents to PDF without interop[^],
Need a rather unique WPF text editor control[^],
Hi how can i display word file in windows application using c#.net[^],
Read a word file without using Interop.word dll...Do not want to install word in IIS..[^].

This is another option: http://npoi.codeplex.com/[^].

—SA
 
Share this answer
 

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