11>click Add reference to ur project select 'com' add reference for microsoftword
2note: The name of your assemblies will vary based upon the version of Word that you have — in my case, it is version 11, or “Microsoft Word 11.0 Object Library.”
32>For C# windows Application
4-----------------------------
5
6add namespace: using Word;
7
8Code to get text from doc to textbox
9-------------------------------------
10 openFileDialog1.ShowDialog();
11 string path = openFileDialog1.FileName.ToString();
12 Word.ApplicationClass wordApp = new ApplicationClass();
13 object file = path;
14 object nullobj = System.Reflection.Missing.Value;
15 Word.Document doc = wordApp.Documents.Open(ref file,ref nullobj, ref nullobj,
16 ref nullobj, ref nullobj, ref nullobj,
17 ref nullobj, ref nullobj, ref nullobj,
18 ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
19 doc.ActiveWindow.Selection.WholeStory();
20 doc.ActiveWindow.Selection.Copy();
21 IDataObject data = Clipboard.GetDataObject();
22 txtload.Text = data.GetData(DataFormats.Text).ToString();
23
24To Read from a Word file using C# in ASP.NET
25---------------------------------------------
26
27string filename="Connectivity.doc";
28if (filename != ""
29{
30string path = Server.MapPath(filename);
31System.IO.FileInfo file = new System.IO.FileInfo(path);
32if (file.Exists)
33{
34Response.Clear();
35Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
36Response.AddHeader("Content-Length", file.Length.ToString());
37Response.ContentType = "application/octet-stream";
38Response.WriteFile(file.FullName);
39Response.End();
40}
41else
42{
43Response.Write("This file does not exist.");
44}
45}
46
47