C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Get the Linecount from a Word file


Posted Date: 21 Jul 2008    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: DharmarajMember Level: Diamond    
Rating: Points: 7



The code sample gets the line count in a word file. It uses the Word namespace. The dll file related to this namespace is given as an attachment.

The function takes the path of the word file as it's argument.


Imports System.IO
Imports Microsoft.VisualBasic
Imports Word
Imports System.Math
Namespace BLL
Public Class WordCount

Public Function lineCount(ByVal fileNamepath As String) As Double

Try
Dim missing As Object = Type.Missing
Dim appWord As Word.Application = New Word.Application
Dim aDoc As Word.Document

aDoc = appWord.Documents.Open(fileNamepath, missing, _
missing, missing, missing, missing, missing, missing, _
missing, missing, missing, missing)

Dim str As String = aDoc.Content.Text
Dim i As Integer
i = aDoc.Words.Count
Dim c As Char
Dim line As Integer = 0
Dim lCount As Double
Dim ii As Integer
For Each c In str
If ((Asc(c) >= 32 AndAlso Asc(c) <= 126) Or Asc(c) = 9 Or Asc(c) = 146) Then
line += 1
Else
Asc(c)
'Dim log As New BLL.FileOperation
'log.WriteLog(Asc(c))
ii = ii + 1
End If
Next
lCount = Math.Ceiling(line / 65)
aDoc.Close()
appWord.Quit()
Return lCount
Catch ex As Exception
Throw
End Try
End Function

End Class
End Namespace




Attachments

  • Word DLL (19664-2167-Interop.Word.dll)



  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Word  .  LineCount of a Word File in VB.NET  .  LineCount of a Word File  .  Get Linecount of a Word File from VB  .  Get Linecount of a Word File  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Change Desktop Wallpaper using VB.NET
    Previous Resource: Degrees to Radians
    Return to Discussion Resource Index
    Post New Resource
    Category: VB.NET Syntax


    Post resources and earn money!
     
    Related Resources



    dotNet Slackers   BizTalk Adaptors    Web Design


    Contact Us    Privacy Policy    Terms Of Use