![]() |
|
#6
|
||||
|
||||
|
There are different ways to calculate a word count in Word. The way the earlier code determines word count is not what a normal English speaker would consider the Word count - it includes punctuation as a word. This code modification uses an alternate method to arrive at a word count and might work better for your documents
Code:
Sub Macro1()
Dim iWords As Double, sFiller As String, arrFiller() As String, i As Integer
sFiller = "I didn't bother to attempt my homework by myself but I asked someone on the internet to do it for me"
arrFiller = Split(sFiller, " ")
iWords = ActiveDocument.Range.ComputeStatistics(wdStatisticWords) 'ActiveDocument.Words.Count
If iWords < 20 Then
For i = 0 To 19 - iWords
ActiveDocument.Range.InsertAfter " " & arrFiller(i)
Next i
End If
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
| Tags |
| vba code, word vba code, word vba macro |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Insert words before and after any italics
|
benfarley | Word VBA | 1 | 03-30-2022 08:35 PM |
| How to find (highlight) two and more words in a list of 75k single words in Word 2010 | Usora | Word | 8 | 05-29-2018 03:34 AM |
How to mark underlined words in a sentence as A, B, C, D (beneath the words)
|
thudangky | Word | 13 | 12-12-2013 02:22 AM |
Macro for highlighting specific number of words
|
icsjohn | Word VBA | 2 | 12-07-2011 06:44 PM |
| Why Words doesn’t show the style of the selected words automatically???? | Jamal NUMAN | Word | 0 | 04-14-2011 03:20 PM |