2013-04-16, 04:51 PM
Indentation is your friend.
Specifically, your problem is that inside the loop between "For Wordcount" and "Next Wordcount" there is one If but two End If.
Code:
Sub CheckWords()
Selection.HomeKey Unit:=wdStory
Dim FirstRound, InQuotes As Boolean
Dim WrongWordCount As Integer
Dim WordCount As Integer
Dim TestingWord As String
WrongWordCount = 0
UnusableWords = Array("i", "me", "you", "us", "we", "my", "mine", "our", "your", "can't", "won't", "should'nt", "you're")
FirstWord = True
InQuotes = False
Do Until Selection.Bookmarks.Exists("\EndOfDoc") = True
If (FirstWord = False) Then Selection.MoveRight (2)
Selection.MoveEndUntil Cset:=" ", Count:=10
TestingWord = NoPunct(Selection)
InQuotes = QuoteState(TestingWord, InQuotes)
If InQuotes = False Then
For WordCount = 0 To UBound(UnusableWords)
If TestingWord = UnusableWords(WordCount) Then
Selection.Range.HighlightColorIndex = wdYellow
WrongWordCount = WrongWordCount + 1
End If
End If [i]This belongs to an If started before the For. Bad nesting.[/i]
Next WordCount
FirstWord = False
Loop
MsgBox ("The Program has finished and found " & WrongWordCount & " unusable words.")Specifically, your problem is that inside the loop between "For Wordcount" and "Next Wordcount" there is one If but two End If.

