Friday, January 21, 2011

How to Extract all words from Word document ??

How To Make Career In QTP: How to Convert Word document to html/pdf ??

retrieves the number of words in the document.
Dim oWord, Doc, currentDocument
Doc = "C:\Test1.docx"
Set oWord = CreateObject("Word.Application")
oWord.DisplayAlerts = 0
oWord.Documents.Open Doc
Set currentDocument = oWord.Documents(1)

Dim nWords, n
nWords = currentDocument.Words.count
Print "Number of Words: " & nWords

For n = 1 to nWords
Print currentDocument.Words(n)
Next
currentDocument.Close
Set currentDocument = Nothing
oWord.Quit
Set oWord = Nothing

No comments:

Post a Comment