Counts number of words in docx files in a folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on error resume next | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
sFolder = "c:\Users\Sean\Desktop\" | |
Set folder = fso.GetFolder(sFolder) | |
Set files = folder.Files | |
Set objWord = CreateObject("Word.Application") | |
iWords = 0 | |
For each folderIdx In files | |
sFileName = Ucase(folderIdx.name) | |
if (right(sFileName,4)) = "DOCX" then | |
Set objDoc = objWord.Documents.Open(sFolder+folderIdx.name) | |
iWords = iWords + objDoc.Words.Count | |
objDoc.close | |
end if | |
Next | |
wscript.echo ("Number of words: " & cStr(iWords)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment