c# 4.0 - Interop word application Error in c# -
I need help with this script I am using Word Interop but I get the following error, why?
Thank you.
Error Set object references to an instance of an object Description: An uncontrolled exception occurred during the execution of existing web requests. For more information about the error, review the stack trace and where it started in the code. Exception Description: System.NullReferenceException: The object reference is not set to an instance of an object. In line .cs This is probably ODOK zero Because the file has failed to load on In addition, it should only be done at one time In addition, using Office Interop is usually a bad idea on the web server:
hold (ex before) {oDoc.Close (ref, riff o, referee o); ClientScript.RegisterStartupScript (this.GetType (), "Error Cobie Williams", "Javascript:; Warning ('" + Pre-message +' '') ");}
oDoc.Close (referee, rif o, referee o);
Using the system; Public Partial Class _Default: System.Web.UI.Page {Secure Zero Page_load (Object Sender, EventArgse E) {// Word Application Microsoft is making an example of Office Office.Interop.phord.appption w = newer Object.Office.Internop.wordpress.exe (); Object path = @ "C: \ inetpub \ wwwroot \ WebSite1 \ Kobie_Williams \ id.docx"; Read object = "Redraw"; Object readonly = False; Object o = System. Reflection.Missing.Value; // Opening document Microsoft.Office.Interop.Word.Documentary oDoc = w.Documents.Open (Ref: referee, reef readon, riff o, riff o, riff o, riff o, riff o , For each paragraph in the document foreach (oDoc.Paragraphs in Microsoft.Office.Interop.Word.Paragraph p), the Riff O, Rif O, Ref, Riff O, Ref O, Riff O, Ref O, Ref. / Lu Try {Microsoft.Office.Interop.Word.Range rng = p.Range; Microsoft.Office.Interop.Word.Style styl = rng.get_Style () as Microsoft.Office.Interop.Word.Style; // Check if the document containg table if ((bool) rng.get_Information (Microsoft.Office.Interop.Word.WdInformation.wdWithInTable) == true) {// In the table foreach loop for each cell (Microsoft.Office.Interop. Word (CRGCNS Seals) {if (rng.Cells.Count> 0) {// Checking the desired area in the table (c.ange.text.ToString (). It contains ("Id") edit // edit values in tables c.Next.Range.Text = "1"; if (C. range.txt.ToString () is included ("name")) c.Next .Range.Text = "Haider"; if (C. range text. Toaster (). ("Address")) c.Next.Range.Text = "cabbie-Williams";}} // saving document oDoc.Save ();}} // closing document oDoc.Close (ref, riff o, Referee o);} hold (ex before) {oDoc.Close (referee, riff o, referee o); ClientScript.RegisterStartupScript (this.GetType (), "Error Cobie Williams", "Javascript:; Warning ('" Message + '' ') ");}}
w.Documents.Open () .
if (odok! = Null) oDoc.Close () blocks
blocks and
hold are not repeated in the block.
Comments
Post a Comment