TmpName = ĭocuments. If (Not ByFreq And Words(l) Freq(k)) Then k = l StatusBar = "Remaining: " & ttlwds & ", Unique: " & WordNum The Word Count dialog box also displays the. You can remove parentheses and comma using search/replace if you want.Īll you need to do download Python 3, install it, open IDLE (comes with Python), replace the content of your word document and run the commands one at a time and in the given order.Ī macro (subroutine) to do exactly what you request is on this page: Sub WordFrequency()Ĭonst maxwords = 9000 'Maximum unique words allowedĭim SingleWord As String 'Raw word pulled from docĭim Words(maxwords) As String 'Array to hold unique wordsĭim Freq(maxwords) As Integer 'Frequency counter for unique wordsĭim WordNum As Integer 'Number of unique wordsĭim ByFreq As Boolean 'Flag for sorting orderĭim ttlwds As Long 'Total words in the documentĭim Excludes As String 'Words to be excludedĭim j, k, l, Temp As Integer 'Temporary variablesĭim ans As String 'How user wants to sort resultsĮxcludes = ""Īns = InputBox("Sort by WORD or by FREQ?", "Sort order", "WORD") The Word Count option on the Tools menu provides an option to determine the number or words in a document. Then we run our function and store its result (word-count pairs) in another list and print the results: result = countWords(wordList) and then generate a word list for our function: import reĬleanContent = re.sub('',' ', content) Here we remove the punctuation, EOL, parentheses etc. (they will be ignored) and numbers like 1 (they will be counted).""" d - t & ' words in the document body, excluding tables. For example: t & ' words in tables.' & vbCr & vbCr & 'There are' & vbCr &. You could, however, use a macro to tally the table word counts and deduct those from the overall count, leaving you with the difference. It can be very very very very long and it can contain punctuation Word cannot exclude a tables contents from the word count. The rest is to manipulate the content of the document.First paste it: content = """This is the content of the word document. Return sorted(ems(), key = lambda item: item, reverse=True) Here we define a simple function which counts words given a list def countWords(a_list): However it's actually just a few line of codes if you're familiar with any programming language.įor example in Python you can easily do it like that: Apart from VBA, one can develop such an application using API of OpenOffice to read the contents of the Word document process it and export the results as a CSV file to open in a spreadsheet application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |