Hi,
I have an app that is using Word for spell-check and after my last machine rebuild I got the brilliant idea that I should upgrade from Office 2003 to office 2007.
Problem is that the spell check no longer works now. it says "Type Word.Application is not defined. (i've included the code below)
Any ideas of how to get it working?
I can't install Office 2007 on every remote PC.
I tried to reinstall office 2003 on my pc, but that did not do the trick... (co-existing that is)
Thank you
Johnny
I have an app that is using Word for spell-check and after my last machine rebuild I got the brilliant idea that I should upgrade from Office 2003 to office 2007.
Problem is that the spell check no longer works now. it says "Type Word.Application is not defined. (i've included the code below)
Any ideas of how to get it working?
I can't install Office 2007 on every remote PC.
I tried to reinstall office 2003 on my pc, but that did not do the trick... (co-existing that is)
Thank you
Johnny
VB.NET:
Private Sub SpellOrGrammarCheck(ByVal blnSpellOnly As Boolean)
Try
' Create Word and temporary document objects.
Dim objWord As Object
Dim objTempDoc As Object
' Declare an IDataObject to hold the data returned from the clipboard.
Dim iData As IDataObject
' If there is no data to spell check, then exit sub here.
If TextBox1.Text = "" Then
Exit Sub
End If
objWord = New Word.Application()
objTempDoc = objWord.Documents.Add
objWord.Visible = False
' Position Word off the screen...this keeps Word invisible throughout.
objWord.WindowState = 0
objWord.Top = -3000
' Copy the contents of the textbox to the clipboard
Clipboard.SetDataObject(TextBox1.Text)
' With the temporary document, perform either a spell check or a complete
' grammar check, based on user selection.
With objTempDoc
.Content.Paste()
.Activate()
If blnSpellOnly Then
.CheckSpelling()
Else
.CheckGrammar()
End If
' After user has made changes, use the clipboard to
' transfer the contents back to the text box
.Content.Copy()
iData = Clipboard.GetDataObject
If iData.GetDataPresent(DataFormats.Text) Then
TextBox1.Text = CType(iData.GetData(DataFormats.Text), String)
End If
.Saved = True
.Close()
End With
objWord.Quit()
MessageBox.Show("The spelling check is complete.", "Spell Checker", MessageBoxButtons.OK, MessageBoxIcon.Information)
' Microsoft Word must be installed.
Catch COMExcep As COMException
MessageBox.Show("Microsoft Word must be installed for Spell/Grammer Check to run.", "Spell Checker")
Catch Excep As Exception
MessageBox.Show("An error has occured.", "Spell Checker")
End Try
End Sub
Last edited by a moderator: