Header Ads

lines counting in word file using asp.net and c#

i have done lines counting in word file while uploading control .....

you shoud add this reference.................

Microsoft.Office.Interop.Word.dll

and try this code.....



if (FileUpload1.HasFile)
{

FileUpload1.SaveAs("Put your path here" + FileUpload1.FileName);
Microsoft.Office.Interop.Word.Application ObjWord = new Microsoft.Office.Interop.Word.Application();
object falseValue = false;
object trueValue = true;
object missing = Type.Missing;
object saveobjections = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
Microsoft.Office.Interop.Word.Document wrdoc;
object filepath = ("Put your path here" + FileUpload1.FileName);
wrdoc = ObjWord.Documents.Open(ref filepath, ref missing, ref trueValue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
Response.Write(wrdoc.ComputeStatistics(Microsoft.Office.Interop.Word.WdStatistic.wdStatisticLines, ref missing));
ObjWord.Documents.Close(ref saveobjections, ref missing, ref missing);
ObjWord.Quit(ref saveobjections, ref missing, ref missing);
}



1 comment:



Powered by Blogger.