I have a function in my program that uses the word spell checker to spell check a text field in my program. It calls one variable by reference which represents the current word in the word list being checked. There is a loop in the code that says if the word is spelled correctly, check next word. The problem i am having is that if the word currently being checked (wrdlst(Wrd)) is spelled correctly, The value of the variable Wrd will get correctly set to the index of the next incorrect word at the end of the function, but when it exits the function, the value of Wrd is not passed back to the refernce variable. It does not have this problem until it finds a correctly spelled work. thanks again.

Code is as follows:

Private Sub CheckNextWord(ByRef Wrd As Integer)
If Wrd > x Then
MsgBox "Spell Check Completed!"
Exit Sub
End If
i = 0
ChangeBtnState False
With Form1.ProbDisc
wrong = True
'************ Heres the loop **********8

While wrong And Wrd < x
wrong = mobjWordApplication.CheckSpelling(WrdLst(Wrd).Text, , True, "C:\Program Files\Common Files\Microsoft Shared\Proof\MSSP3EN.LEX")
If wrong Then Wrd = Wrd + 1
Wend
'************ That was the loop ********

.SelStart = WrdLst(Wrd).BeginPos - 1
.SelLength = WrdLst(Wrd).EndPos - WrdLst(Wrd).BeginPos + 1
StatusBar1.SimpleText = WrdLst(Wrd).Text
If Not wrong Then
Set mobjSuggestions = Nothing
Set mobjSuggestions = mobjWordApplication.GetSpellingSuggestions(WrdLst(Wrd).Text)
For Each objSuggestion In mobjSuggestions
List1.AddItem CStr(objSuggestion.Name), i
i = i + 1
Next
End If
If i > 0 Then List1.ListIndex = 0
Text1.Text = List1.Text
End With
ChangeBtnState True
End Sub