Export DataTable To MS Word in C#http://forums.asp.net/t/1069346.aspx/1?Export+DataTable+To+MS+Word+in+C+Wed, 29 Dec 2010 11:09:40 -050010693461555658http://forums.asp.net/p/1069346/1555658.aspx/1?Export+DataTable+To+MS+Word+in+C+Export DataTable To MS Word in C# <p>Hello All,</p> <p>I have a DataTable with data now I want to export those data to a MS Word document(Report) in a table.I figure out the following code....but can't able to add data to the word table.Is there anyone who can help me?</p> <font size="2"> <p>Word.ApplicationClass wa = </font><font color="#0000ff" size="2">new</font><font size="2"> Word.ApplicationClass();</p> <p>wa.Visible=</font><font color="#0000ff" size="2">true</font><font size="2">;</p> <p>Word.DocumentClass wd = </font><font color="#0000ff" size="2">new</font><font size="2"> Word.DocumentClass();</p> <p>wd.Activate();</p> <p>Object start = Type.Missing;</p> <p>Object end = Type.Missing;</p> <p>Word.Range rng = wd.Range(</font><font color="#0000ff" size="2">ref</font><font size="2"> start, </font><font color="#0000ff" size="2">ref</font><font size="2"> end);</p> <p>Object defaultTableBehavior = Type.Missing;</p> <p>Object autoFitBehavior = Type.Missing;</p> <p>wd.Tables.Add(rng, 1, 3, </p> <p></font><font color="#0000ff" size="2">ref</font><font size="2"> defaultTableBehavior, </font><font color="#0000ff" size="2">ref</font><font size="2"> autoFitBehavior);</font></p> <p><font size="2">The above code only create a word table I how can I insert data from a datatable in this word table?</font></p> <p><font size="2">Thanks in advance</p> </font> 2007-01-30T15:40:36-05:001555898http://forums.asp.net/p/1069346/1555898.aspx/1?Re+Export+DataTable+To+MS+Word+in+C+Re: Export DataTable To MS Word in C# <p>I just figure out the issue and its working now....Here is the code</p> <font color="#0000ff" size="2"> <p>private</font><font size="2"> </font><font color="#0000ff" size="2">void</font><font size="2"> button3_Click(</font><font color="#0000ff" size="2">object</font><font size="2"> sender, System.EventArgs e)</p> <p>{</p> <p>Word.DocumentClass wd = </font><font color="#0000ff" size="2">new</font><font size="2"> Word.DocumentClass();</p> <p>wd.Activate();</p> <p></font><font color="#008000" size="2">//ADD TEXT</p> </font><font size="2"> <p></font><font color="#008000" size="2">//wd.Content.Text=&quot;&lt;table&gt;&lt;/table&gt;&quot;;</p> </font><font size="2"> <p></font><font color="#008000" size="2">//END ADD TEXT</p> </font><font size="2"> <p>Object start = Type.Missing;</p> <p>Object end = Type.Missing;</p> <p>Word.Range rng = wd.Range(</font><font color="#0000ff" size="2">ref</font><font size="2"> start, </font><font color="#0000ff" size="2">ref</font><font size="2"> end);</p> <p>Object defaultTableBehavior = Type.Missing;</p> <p>Object autoFitBehavior = Type.Missing;</p> <p></font><font color="#0000ff" size="2">object</font><font size="2"> missing = System.Type.Missing;</p> <p></font><font color="#008000" size="2">//ADD TABLE</p> </font><font size="2"> <p>Word.Table tbl = wd.Tables.Add</p> <p>(rng,1, 5, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing);</p> <p></font><font color="#008000" size="2">//END ADD TABLE</p> </font><font size="2"> <p></font><font color="#008000" size="2">//SET HEADER</p> </font><font size="2"> <p>SetHeadings(tbl.Cell(1, 1), &quot;Permit Type&quot;);</p> <p>SetHeadings(tbl.Cell(1, 2), &quot;Completeness Determination&quot;);</p> <p>SetHeadings(tbl.Cell(1, 3), &quot;Draft Permit&quot;);</p> <p>SetHeadings(tbl.Cell(1, 4), &quot;Final Decision&quot;);</p> <p>SetHeadings(tbl.Cell(1, 5), &quot;Other Target&quot;);</p> <p></font><font color="#008000" size="2">//END SET HEADER</p> </font><font size="2"> <p></font><font color="#008000" size="2">//ADD ROW</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">for</font><font size="2">(</font><font color="#0000ff" size="2">int</font><font size="2"> i=0;i&lt;fds.Rows.Count;i&#43;&#43;)</p> <p>{</p> <p>Word.Row newRow = wd.Tables[1].Rows.Add(</font><font color="#0000ff" size="2">ref</font><font size="2"> missing);</p> <p>newRow.Range.Font.Bold = 0;</p> <p>newRow.Range.ParagraphFormat.Alignment = </p> <p>Word.WdParagraphAlignment.wdAlignParagraphLeft;</p> <p>&nbsp;</p> <p>newRow.Cells[1].Range.Text = fds.Rows[i][0].ToString();</p> <p>newRow.Cells[2].Range.Text = fds.Rows[i][1].ToString();</p> <p>newRow.Cells[3].Range.Text = fds.Rows[i][2].ToString();</p> <p>newRow.Cells[4].Range.Text = fds.Rows[i][3].ToString();;</p> <p>newRow.Cells[5].Range.Text = fds.Rows[i][4].ToString();</p> <p>}</p> <p>&nbsp;</p> <p></font><font color="#008000" size="2">//END ROW</p> <p>&nbsp;</p> <p>&nbsp;</p> </font><font size="2"> <p>}</p> <p></font><font color="#008000" size="2">//ADD HEADER</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">static</font><font size="2"> </font><font color="#0000ff" size="2">void</font><font size="2"> SetHeadings(Word.Cell tblCell, </font><font color="#0000ff" size="2">string</font><font size="2"> text)</p> <p>{</p> <p>tblCell.Range.Text = text;</p> <p>tblCell.Range.Font.Bold = 1;</p> <p>tblCell.Range.ParagraphFormat.Alignment = </p> <p>Word.WdParagraphAlignment.wdAlignParagraphCenter;</p> <p>}</p> <p></font><font color="#008000" size="2">//ADD HEADER</p> </font> 2007-01-30T18:09:28-05:001555899http://forums.asp.net/p/1069346/1555899.aspx/1?Re+Export+DataTable+To+MS+Word+in+C+Re: Export DataTable To MS Word in C# <p>I just figure out the issue and its working now....Here is the code</p> <font color="#0000ff" size="2"> <p>private</font><font size="2"> </font><font color="#0000ff" size="2">void</font><font size="2"> button3_Click(</font><font color="#0000ff" size="2">object</font><font size="2"> sender, System.EventArgs e)</p> <p>{</p> <p>Word.DocumentClass wd = </font><font color="#0000ff" size="2">new</font><font size="2"> Word.DocumentClass();</p> <p>wd.Activate();</p> <p></font><font color="#008000" size="2">//ADD TEXT</p> </font><font size="2"> <p></font><font color="#008000" size="2">//wd.Content.Text=&quot;&lt;table&gt;&lt;/table&gt;&quot;;</p> </font><font size="2"> <p></font><font color="#008000" size="2">//END ADD TEXT</p> </font><font size="2"> <p>Object start = Type.Missing;</p> <p>Object end = Type.Missing;</p> <p>Word.Range rng = wd.Range(</font><font color="#0000ff" size="2">ref</font><font size="2"> start, </font><font color="#0000ff" size="2">ref</font><font size="2"> end);</p> <p>Object defaultTableBehavior = Type.Missing;</p> <p>Object autoFitBehavior = Type.Missing;</p> <p></font><font color="#0000ff" size="2">object</font><font size="2"> missing = System.Type.Missing;</p> <p></font><font color="#008000" size="2">//ADD TABLE</p> </font><font size="2"> <p>Word.Table tbl = wd.Tables.Add</p> <p>(rng,1, 5, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing);</p> <p></font><font color="#008000" size="2">//END ADD TABLE</p> </font><font size="2"> <p></font><font color="#008000" size="2">//SET HEADER</p> </font><font size="2"> <p>SetHeadings(tbl.Cell(1, 1), &quot;Permit Type&quot;);</p> <p>SetHeadings(tbl.Cell(1, 2), &quot;Completeness Determination&quot;);</p> <p>SetHeadings(tbl.Cell(1, 3), &quot;Draft Permit&quot;);</p> <p>SetHeadings(tbl.Cell(1, 4), &quot;Final Decision&quot;);</p> <p>SetHeadings(tbl.Cell(1, 5), &quot;Other Target&quot;);</p> <p></font><font color="#008000" size="2">//END SET HEADER</p> </font><font size="2"> <p></font><font color="#008000" size="2">//ADD ROW</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">for</font><font size="2">(</font><font color="#0000ff" size="2">int</font><font size="2"> i=0;i&lt;fds.Rows.Count;i&#43;&#43;)</p> <p>{</p> <p>Word.Row newRow = wd.Tables[1].Rows.Add(</font><font color="#0000ff" size="2">ref</font><font size="2"> missing);</p> <p>newRow.Range.Font.Bold = 0;</p> <p>newRow.Range.ParagraphFormat.Alignment = </p> <p>Word.WdParagraphAlignment.wdAlignParagraphLeft;</p> <p>&nbsp;</p> <p>newRow.Cells[1].Range.Text = fds.Rows[i][0].ToString();</p> <p>newRow.Cells[2].Range.Text = fds.Rows[i][1].ToString();</p> <p>newRow.Cells[3].Range.Text = fds.Rows[i][2].ToString();</p> <p>newRow.Cells[4].Range.Text = fds.Rows[i][3].ToString();;</p> <p>newRow.Cells[5].Range.Text = fds.Rows[i][4].ToString();</p> <p>}</p> <p>&nbsp;</p> <p></font><font color="#008000" size="2">//END ROW</p> <p>&nbsp;</p> <p>&nbsp;</p> </font><font size="2"> <p>}</p> <p></font><font color="#008000" size="2">//ADD HEADER</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">static</font><font size="2"> </font><font color="#0000ff" size="2">void</font><font size="2"> SetHeadings(Word.Cell tblCell, </font><font color="#0000ff" size="2">string</font><font size="2"> text)</p> <p>{</p> <p>tblCell.Range.Text = text;</p> <p>tblCell.Range.Font.Bold = 1;</p> <p>tblCell.Range.ParagraphFormat.Alignment = </p> <p>Word.WdParagraphAlignment.wdAlignParagraphCenter;</p> <p>}</p> <p></font><font color="#008000" size="2">//ADD HEADER</p> </font> 2007-01-30T18:09:50-05:001946958http://forums.asp.net/p/1069346/1946958.aspx/1?Re+Export+DataTable+To+MS+Word+in+C+Re: Export DataTable To MS Word in C# <p>hi All Iam try this code but gettting error at </p> <p><font color="#0000ff" size="2">Dim</font><font size="2"> wd </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">New</font><font size="2"> Word.DocumentClass()</font></p> <p><font size="2">error is -- Word.DocumentClass() is not defined.</font></p> <p><font size="2">Is there any dll t be included or wat is the sol's</font></p> <p>enviornment ---Asp.net, vb.net</p> <p><font size="2">reply soon</font></p> <p><font size="2">with regards </font></p> <p><font size="2">ajay</p> </font> 2007-10-09T07:04:31-04:002402164http://forums.asp.net/p/1069346/2402164.aspx/1?Do+you+have+the+Office+2007+PIA+Do you have the Office 2007 PIA? <p>Hi, My name is Diego Toala from Ecuador,South America , if you wanna use the&nbsp;Word.DocumentClass() you need&nbsp;to add a reference&nbsp;to the MSOffice 2007 PIA (Primary Interop Assembly) in your project , you can find all the office reference in&nbsp;the Redistributable MSOffice 2007 PIA installer&nbsp;package and you can download the installer package from here <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=59daebaa-bed4-4282-a28c-b864d8bfa513&amp;displaylang=en"> http://www.microsoft.com/downloads/details.aspx?FamilyID=59daebaa-bed4-4282-a28c-b864d8bfa513&amp;displaylang=en</a>&nbsp;, install the package and you get the <span style="font-size:10pt; font-family:'Verdana','sans-serif'">Microsoft.Office.Interop.Word assembly...</span></p> <p><span style="font-size:10pt; font-family:'Verdana','sans-serif'">&nbsp;Open the Visual Studio 2005, Open your Project , then right click in the &quot;References&quot; folder, Choose &quot;Add Reference&quot;, Choose the &quot;CoM&quot; tab, then choose the &quot;Microsoft Office 12 Object Library&quot; option,,, now you can use all the word interop classes in the Namespace <span style="font-size:10pt; font-family:'Verdana','sans-serif'"> Microsoft.Office.Interop.Word .</span></span></p> <p><span style="font-size:10pt; font-family:'Verdana','sans-serif'"><span style="font-size:10pt; font-family:'Verdana','sans-serif'">Check the assembly, type&nbsp; Microsoft.Office.Interop.Word.DocumentCl... and the intellisense make it all for you.</span></span></p> <span style="font-size:10pt; font-family:'Verdana','sans-serif'"><span style="font-size:10pt; font-family:'Verdana','sans-serif'">&nbsp;Here is a code sample:<font size="2"></font></span></span><span style="font-size:10pt; font-family:'Verdana','sans-serif'"><span style="font-size:10pt; font-family:'Verdana','sans-serif'"><font size="2"> <p>Microsoft.Office.Interop.Word.</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">ApplicationClass</font></font><font size="2"> wa = </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font size="2"> Microsoft.Office.Interop.Word.</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">ApplicationClass</font></font><font size="2">();</p> wa.Visible = </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">true</font></font><font size="2">;</font><font size="2">Microsoft.Office.Interop.Word.</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">DocumentClass</font></font><font size="2"> wd = </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font size="2"> Microsoft.Office.Interop.Word.</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">DocumentClass</font></font><font size="2">();</font><font size="2"> <p>wd.Activate();</p> <p></font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Object</font></font><font size="2"> start = </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Type</font></font><font size="2">.Missing;</p> </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Object</font></font><font size="2"> end = </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Type</font></font><font size="2">.Missing;</font><font size="2"> <p>Microsoft.Office.Interop.Word.</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Range</font></font><font size="2"> wr = wd.Range(</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">ref</font></font><font size="2"> start, </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">ref</font></font><font size="2"> end);</p> </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Object</font></font><font size="2"> defaultTableBehavior = </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Type</font></font><font size="2">.Missing;</font><font size="2"> <p></font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Object</font></font><font size="2"> autoFitBehavior = </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Type</font></font><font size="2">.Missing;</p> </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Object</font></font><font size="2"> missing = </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Type</font></font><font size="2">.Missing;</font><font size="2"> <p>Microsoft.Office.Interop.Word.</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Table</font></font><font size="2"> wtable= wd.Tables.Add(wr, 1,1,</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">ref</font></font><font size="2"> missing, </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">ref</font></font><font size="2"> missing);</p> <p>SetHeadings(wtable.Cell(1, 0), </font><font color="#a31515" size="2"><font color="#a31515" size="2">&quot;Ejemplo - Example&quot;</font></font><font size="2">);</font></p> <p><font size="2"></font>&nbsp;</p> <p><font size="2">put in the load method of your form, see you, i hope this little articule , fits your needs.</font></p> <p><font size="2">Diego Toala</p> </font></span></span> <p><span style="font-size:10pt; font-family:'Verdana','sans-serif'"><span style="font-size:10pt; font-family:'Verdana','sans-serif'"></span></span>&nbsp;</p> 2008-06-04T21:36:36-04:002402278http://forums.asp.net/p/1069346/2402278.aspx/1?Re+Do+you+have+the+Office+2007+PIA+Re: Do you have the Office 2007 PIA? <p>Does anyone perhaps know of good resources to start using PIA? I want to generate Word documents that clients can save.</p> <p>Also would the web server that hosts the website need to have PIA's installed or could i copy the dll to my bin folder instead of GAC?</p> 2008-06-04T22:47:45-04:002404212http://forums.asp.net/p/1069346/2404212.aspx/1?LinksLinks <p>Hi Jacques, review this links, for a full information about office's PIAs , i recommend the MSDN and CodeProject Websites.</p> <p><a href="http://msdn.microsoft.com/en-us/library/15s06t57.aspx">http://msdn.microsoft.com/en-us/library/15s06t57.aspx</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/kh3965hw.aspx">http://msdn.microsoft.com/en-us/library/kh3965hw.aspx</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/76d2d007.aspx">http://msdn.microsoft.com/en-us/library/76d2d007.aspx</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/hy7c6z9k.aspx">http://msdn.microsoft.com/en-us/library/hy7c6z9k.aspx</a></p> <p><a href="http://www.codeproject.com/">http://www.codeproject.com</a></p> <p><a href="http://www.codeproject.com/info/search.aspx?artkw=Office&#43;PIA">http://www.codeproject.com/info/search.aspx?artkw=Office&#43;PIA</a></p> <p><a href="http://blogs.msdn.com/artleo/archive/2006/03/24/560418.aspx">http://blogs.msdn.com/artleo/archive/2006/03/24/560418.aspx</a></p> <p>the last one is the ArtLeo's WebLog , very good.</p> <p>Enjoy.[:D]</p> <p>{diego toala}</p> 2008-06-05T15:07:28-04:002404407http://forums.asp.net/p/1069346/2404407.aspx/1?Re+Export+DataTable+To+MS+Word+in+C+Re: Export DataTable To MS Word in C# <p></p> <blockquote><span class="icon-blockquote"></span> <h4>arnabdt</h4> <p>Hello All,</p> <p>I have a DataTable with data now I want to export those data to a MS Word document(Report) in a table.I figure out the following code....but can't able to add data to the word table.Is there anyone who can help me?</p> <font size="2"> <p>Word.ApplicationClass wa = </p> </font><font color="#0000ff" size="2">new</font><font size="2"> Word.ApplicationClass(); <p>wa.Visible=</p> </font><font color="#0000ff" size="2">true</font><font size="2">; <p>Word.DocumentClass wd = </p> </font><font color="#0000ff" size="2">new</font><font size="2"> Word.DocumentClass(); <p>wd.Activate();</p> <p>Object start = Type.Missing;</p> <p>Object end = Type.Missing;</p> <p>Word.Range rng = wd.Range(</p> </font><font color="#0000ff" size="2">ref</font><font size="2"> start, </font><font color="#0000ff" size="2">ref</font><font size="2"> end); <p>Object defaultTableBehavior = Type.Missing;</p> <p>Object autoFitBehavior = Type.Missing;</p> <p>wd.Tables.Add(rng, 1, 3, </p> <p>&nbsp;</p> </font><font color="#0000ff" size="2">ref</font><font size="2"> defaultTableBehavior, </font><font color="#0000ff" size="2">ref</font><font size="2"> autoFitBehavior);</font> <p><font size="2">The above code only create a word table I how can I insert data from a datatable in this word table?</font></p> <p><font size="2">Thanks in advance</font></p> <p></p> </blockquote> <p></p> <p>Please remark that Microsoft does not recoment to use ActiveX/OLE controls of Word /Excel/e.t.c. &nbsp;on servers.</p> <p>Alexei Cioina.</p> <p><a href="http://www.californiadreamhomesandland.com/">http://www.californiadreamhomesandland.com</a></p> 2008-06-05T16:20:39-04:002442013http://forums.asp.net/p/1069346/2442013.aspx/1?Re+Export+DataTable+To+MS+Word+in+C+Re: Export DataTable To MS Word in C# <p>&nbsp;Hai...</p> <p>pls tell me how to add header and footer in ms-word using C#.<br> </p> <p>thanxs..</p> <p>&nbsp;</p> 2008-06-24T05:16:06-04:004219812http://forums.asp.net/p/1069346/4219812.aspx/1?Adding+Header+and+footer+To+MS+Word+in+C+Adding Header and footer To MS Word in C# <pre class="prettyprint">object oTrue = true; object oFalse = false; object oMissing = System.Reflection.Missing.Value; object novalue=System.Reflection.Missing.Value; object missing=System.Reflection.Missing.Value; object fileName = &quot;normal.dot&quot;; object newTemplate=false; object docType=0; object isVisible=true; Microsoft.Office.Interop.Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass(); Microsoft.Office.Interop.Word.Document aDoc= WordApp.Documents.Add(ref fileName, ref newTemplate, ref docType, ref isVisible); WordApp.Visible = true; aDoc.Activate(); string logoPath = Server.MapPath(&quot;~//Images//logo.JPG&quot;); Microsoft.Office.Interop.Word.Shape logoCustom = null; WordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageHeader; logoCustom = WordApp.Selection.HeaderFooter.Shapes.AddPicture(logoPath, ref oFalse, ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); logoCustom.Select(ref oMissing); logoCustom.Name = &quot;CustomLogo&quot;; logoCustom.Left = -47; logoCustom.Top = -16; WordApp.ActiveWindow.ActivePane.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageFooter; WordApp.ActiveWindow.Selection.Font.Name = &quot;Verdana&quot;; WordApp.ActiveWindow.Selection.Font.Size=8; Object CurrentPage = Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage; WordApp.ActiveWindow.Selection.TypeText(&quot;For Logica Internal Use Only&quot;); WordApp.ActiveWindow.Selection.TypeText(&quot; &quot;); WordApp.ActiveWindow.Selection.TypeText(&quot;Page &quot;); WordApp.ActiveWindow.Selection.Fields.Add(WordApp.Selection.Range, ref CurrentPage, ref oMissing, ref oMissing); WordApp.ActiveWindow.Selection.TypeText(&quot; &quot;); WordApp.ActiveWindow.Selection.TypeText(DateTime.Today.ToString(&quot;MM/dd/yyyy&quot;));</pre> <p>Regards,</p> <p>Manu<br> </p> 2010-12-21T06:13:12-05:004229739http://forums.asp.net/p/1069346/4229739.aspx/1?Re+Adding+Header+and+footer+To+MS+Word+in+C+Re: Adding Header and footer To MS Word in C# <p>There is a need to add&nbsp;two more users in DCOM Config: &nbsp;In Computer Services-&gt;Computers-&gt;My Computer-&gt;DCOM Config-&gt;Microsoft Office Word 97-2003 Document, Security tab-&gt; add everywhere iusr and iwam, give all the permissions to that users. Now it will work.&nbsp;<img title="Smile" alt="Smile" src="http://forums.asp.net/tiny_mce/jscripts/tiny_mce/plugins/emotions/img/smiley-smile.gif" border="0"></p> 2010-12-29T11:09:40-05:00