Results 1 to 8 of 8

Thread: counting charecters and lines in word

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179

    counting charecters and lines in word

    Hi

    i want to count charecters and lines from a word file
    where i'll select the file for which i want to count charecters and lines through vb6
    could some one help me pls its urgent

  2. #2
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872
    VB Code:
    1. Dim appWord As New Word.Application
    2. Dim docWord As New Word.Document
    3.  
    4. appWord.Documents.Open App.Path & "\new.doc"
    5. Set docWord = appWord.Documents(1)
    6.  
    7. MsgBox docWord.Content.ComputeStatistics(wdStatisticCharacters)
    8. MsgBox docWord.Content.ComputeStatistics(wdStatisticWords)
    9. MsgBox docWord.Content.ComputeStatistics(wdStatisticLines)
    10. MsgBox docWord.Content.ComputeStatistics(wdStatisticParagraphs)
    11. MsgBox docWord.Content.ComputeStatistics(wdStatisticPages)
    12.  
    13.  
    14.  
    15. docWord.Close (0)
    16. appWord.Quit
    17. Set docWord = Nothing
    18. Set appWord = Nothing
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179
    can i open multiple files and take the count of charecters..?
    where can i download microsoft word object library 9.0

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    the library cannot be downloaded, neither redistributed
    -= a peet post =-

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179
    but it is giving me an error
    and the library is not available into the reference also
    how should i do it

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    install office
    -= a peet post =-

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179
    office 97 is already installed on the machine
    but still it is giving an error

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    try using late binding

    VB Code:
    1. Option Explicit
    2.  
    3. Public objWord As Object 'instead of Word.Application
    4. Public wd As Object  'instead of Word.Document
    5.  
    6. Private Sub Command1_Click()
    7.  
    8.     If objWord Is Nothing Then
    9.         Set objWord = CreateObject("Word.Application")
    10.     Else
    11.         Set objWord = GetObject(, "Word.Application")
    12.     End If
    13.     DoEvents
    14.     Set wd = objWord.Documents.Open("c:\Test.doc")
    15.     'here u can do stuff with the document
    16.     'using the wd object
    17.        
    18.     'adding some text to it
    19.     wd.ActiveWindow.Selection.TypeText "ABCDEFGH peet was here ! :-)"
    20.    
    21.     'when finished manipulating the document, u can show it To the user
    22.     objWord.Visible = True
    23.  
    24.     'quit word
    25.     If Not (wd Is Nothing) Then Set wd = Nothing
    26.     If Not (objWord Is Nothing) Then objWord.Application.Quit
    27.     If Not (objWord Is Nothing) Then Set objWord = Nothing
    28. End Sub
    -= a peet post =-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width