Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft word must be installed for spell Grammer Check to run! 1

Status
Not open for further replies.

lehuong

Programmer
Sep 2, 2003
98
0
0
US
Hi all,
I got this error "Microsoft word must be installed for spell Grammer Check to run!" when I do the spell check code bellow. The it does the first spell check then the error appears. Anyone familiar with this problems?

Dim strConsequense As String
Dim objWord As Object
Dim objTempDoc As Object
Dim iData As IDataObject
objWord = New Word.Application
objTempDoc = objWord.Documents.Add

'***Do loop here
Do While fSpellCheck
objWord.Visible = False
objWord.WindowState = 0
objWord.Top = -3000
Clipboard.SetDataObject(RichTextBox1.Text.Trim)
With objTempDoc
.Content.Paste()
.Activate()
.CheckSpelling()
.Content.Copy()
iData = Clipboard.GetDataObject
If iData.GetDataPresent(DataFormats.Text) Then
RichTextBox1.Text = CType(iData.GetData(DataFormats.Text), String)
End If
.Saved = True
End With

Clipboard.SetDataObject(RichTextBox2.Text)

With objTempDoc
.Content.Paste()
.Activate()
.CheckSpelling()
.Content.Copy()
iData = Clipboard.GetDataObject
If iData.GetDataPresent(DataFormats.Text) Then
RichTextBoxWorksheetConsequence.Text = CType(iData.GetData(DataFormats.Text), String)
End If
.Saved = True

End With

LoadDataNext()
If i = dv.Count - 1 Then
fSpellCheck = False
Exit Do
End If
i += 1
Loop
'***End loop

objTempDoc.Close()

objTempDoc = Nothing
objWord.Quit()
objWord = Nothing

Thanks

lehuong
 
Here is the exact code that come up with the error (there is an error in COMExcep), anyone know what is wrong?

try
Dim strConsequense As String
Dim objWord As Object
Dim objTempDoc As Object
Dim iData As IDataObject
objWord = New Word.Application
objTempDoc = objWord.Documents.Add

'***Do loop here
Do While fSpellCheck
objWord.Visible = False
objWord.WindowState = 0
objWord.Top = -3000
Clipboard.SetDataObject(RichTextBox1.Text.Trim)
With objTempDoc
.Content.Paste()
.Activate()
.CheckSpelling()
.Content.Copy()
iData = Clipboard.GetDataObject
If iData.GetDataPresent(DataFormats.Text) Then
RichTextBox1.Text = CType(iData.GetData(DataFormats.Text), String)
End If
.Saved = True
End With

Clipboard.SetDataObject(RichTextBox2.Text)

With objTempDoc
.Content.Paste()
.Activate()
.CheckSpelling()
.Content.Copy()
iData = Clipboard.GetDataObject
If iData.GetDataPresent(DataFormats.Text) Then
RichTextBoxWorksheetConsequence.Text = CType(iData.GetData(DataFormats.Text), String)
End If
.Saved = True

End With

LoadDataNext()
If i = dv.Count - 1 Then
fSpellCheck = False
Exit Do
End If
i += 1
Loop
'***End loop

objTempDoc.Close()

objTempDoc = Nothing
objWord.Quit()
objWord = Nothing


Catch COMExcep As COMException
MessageBox.Show("Microsoft Word must be installed for Spell/Grammer Check to run.", "Spell Checker")
End try

Thanks

lehuong
 
You're instantiating Word objects. How do you expect it to run without Word being installed???

Craig
 
Have you tried running custom install and only installing Spelling tools? I'd be interested to see if it worked.
 
No, I have the Microsoft Word installed. It worked for the first check and the second check it appeared the error.
lehuong
 

To see the real error, replace the line
Code:
MessageBox.Show("Microsoft Word must be installed for Spell/Grammer Check to run.", "Spell Checker")

with

Code:
MessageBox.Show(COMExcep.toString)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top