hii all I have developed a small web application which is working fine on my machine.Now after deployment of my project to a server,the code that used to do page counting of word document is not working and is giving me an error saying...
Server Error in '/recordsmanagement' Application.
Object reference not set to an instance of an object.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 412:
Line 413: Microsoft.Office.Interop.Word.WdStatistic stat = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;
Line 414: count = aDoc.ComputeStatistics(stat, ref missing);
Line 414 is giving me the error:
The whole piece of code is like this:
Microsoft.Office.Interop.Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
// give any file name of your choice.
string tempath = numberofpage;
RegexOptions options = RegexOptions.None;
Regex regex = new Regex(@"[ ]{2,}", options);
tempath = regex.Replace(tempath, @"");
tempath = tempath.Replace(" \\", "\\");
object fileName = tempath;
object readOnly = false;
object isVisible = true;
// the way to handle parameters you don't care about in .NET
object missing = System.Reflection.Missing.Value;
object objDNS = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
// Make word visible, so you can see what's happening
//WordApp.Visible = true;
// Open the document that was chosen by the dialog
Microsoft.Office.Interop.Word.Document aDoc = WordApp.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);
Microsoft.Office.Interop.Word.WdStatistic stat = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;
count = aDoc.ComputeStatistics(stat, ref missing);
harrypsd
0 Points
3 Posts
Page Count of Word Document
Nov 25, 2012 10:02 PM|LINK
hii all I have developed a small web application which is working fine on my machine.Now after deployment of my project to a server,the code that used to do page counting of word document is not working and is giving me an error saying...
Server Error in '/recordsmanagement' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 412:Line 413: Microsoft.Office.Interop.Word.WdStatistic stat = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;Line 414: count = aDoc.ComputeStatistics(stat, ref missing);Line 414 is giving me the error:The whole piece of code is like this:Microsoft.Office.Interop.Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
// give any file name of your choice.
string tempath = numberofpage;
RegexOptions options = RegexOptions.None;
Regex regex = new Regex(@"[ ]{2,}", options);
tempath = regex.Replace(tempath, @"");
tempath = tempath.Replace(" \\", "\\");
object fileName = tempath;
object readOnly = false;
object isVisible = true;
// the way to handle parameters you don't care about in .NET
object missing = System.Reflection.Missing.Value;
object objDNS = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
// Make word visible, so you can see what's happening
//WordApp.Visible = true;
// Open the document that was chosen by the dialog
Microsoft.Office.Interop.Word.Document aDoc = WordApp.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);
Microsoft.Office.Interop.Word.WdStatistic stat = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;
count = aDoc.ComputeStatistics(stat, ref missing);
WordApp.Quit(ref objDNS, ref missing, ref missing);
aDoc = null;
WordApp = null;
GC.Collect();
Does anyone have ever come across this suituation>I would be very thank for any kind of help in regards to the above issueDreamBig
Participant
1339 Points
622 Posts
Re: Page Count of Word Document
Nov 26, 2012 06:14 AM|LINK
check this link - http://www.codeproject.com/Questions/490201/PageplusCountplusinplusWordplusdoc
Hope it helps..
My Blog
Shailendra S...
Member
551 Points
145 Posts
Re: Page Count of Word Document
Nov 30, 2012 11:22 AM|LINK
did you check is msoffice is installed on your server.
www.techaray.com