catgirl78
March 21st, 2001, 07:40 PM
i have a form with a text box and a list box. when the user type in the text box, a list of word suggestion would display in the list box. I had set the reference to word object but errors still occur. the codes i used are as below:
the error i received when i started typing in the textbox is "object variable or with block varilable not set"
'name of listbox = lstCorrect
'name of textbox =txt_ResFree
in the module.bas:
Public SC As Word.Application
Public Doc As Document
Public SpellErrors As SpellingSuggestions
Public SpellError As SpellingSuggestion
Public Sub Main()
Set SC = New Word.Application
SC.Visible = False
Set Doc = SC.Documents.Open(AppPath& "Blank.doc")
frmSpell.Show
End Sub
Public Function AppPath() As String
Dim sAns As String
sAns = App.Path
If Right(App.Path, 1) <> "\" Then sAns = sAns & "\"
AppPath = sAns
End Function
in the form:
Private Sub txt_ResFree_Change()
lstCorrect.Visible = True
lstCorrect.Clear
Set SpellErrors = SC.GetSpellingSuggestions(Word:=txt_ResFree.Text)
If SpellErrors.Count > 0 Then
For Each SpellError In SpellErrors
lstCorrect.AddItem SpellError.Name
Next SpellError
ElseIf SC.CheckSpelling(Word:=txt_ResFree.Text) Then
lstCorrect.AddItem txt_ResFree.Text
End If
End Sub
Private Sub lstCorrect_DblClick()
Dim sel As Integer
Clipboard.Clear
Clipboard.SetText lstCorrect.Text
txt_ResFree.Text = lstCorrect.Text
End Sub
Please HELP!!..
thanks
the error i received when i started typing in the textbox is "object variable or with block varilable not set"
'name of listbox = lstCorrect
'name of textbox =txt_ResFree
in the module.bas:
Public SC As Word.Application
Public Doc As Document
Public SpellErrors As SpellingSuggestions
Public SpellError As SpellingSuggestion
Public Sub Main()
Set SC = New Word.Application
SC.Visible = False
Set Doc = SC.Documents.Open(AppPath& "Blank.doc")
frmSpell.Show
End Sub
Public Function AppPath() As String
Dim sAns As String
sAns = App.Path
If Right(App.Path, 1) <> "\" Then sAns = sAns & "\"
AppPath = sAns
End Function
in the form:
Private Sub txt_ResFree_Change()
lstCorrect.Visible = True
lstCorrect.Clear
Set SpellErrors = SC.GetSpellingSuggestions(Word:=txt_ResFree.Text)
If SpellErrors.Count > 0 Then
For Each SpellError In SpellErrors
lstCorrect.AddItem SpellError.Name
Next SpellError
ElseIf SC.CheckSpelling(Word:=txt_ResFree.Text) Then
lstCorrect.AddItem txt_ResFree.Text
End If
End Sub
Private Sub lstCorrect_DblClick()
Dim sel As Integer
Clipboard.Clear
Clipboard.SetText lstCorrect.Text
txt_ResFree.Text = lstCorrect.Text
End Sub
Please HELP!!..
thanks