Hi All,
Hopefully this is a nice simple one for someone who knows more than I do. I have some code that runs a textbox through grammar checker in word. The only problem with it is that if I have anything else open then it hides underneath it and the only way to show it is by hitting the desktop button and then maximising the workbook again.
If anyone has any suggestions I would be very grateful.
Thanks, the code is as follows:
Private Sub CommandButton2_Click()
Dim objWord As Object
Dim objDoc As Object
Dim strResult As String
'Create a new instance of word application
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
objDoc.Content = TextProjectDesc.Text
objDoc.CheckGrammar '''IT IS THIS THAT HIDES UNDERNEATH OTHER APPLICATIONS
objWord.Visible = False
strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)
strResult = Replace(strResult, Chr(13), Chr(13) & Chr(10))
'Clean Up
objDoc.Close False
Set objDoc = Nothing
objWord.Application.Quit True
Set objWord = Nothing
If TextProjectDesc.Text = strResult Then
MsgBox "The Spelling check is complete, and there were no errors.", vbInformation + vbOKOnly
End If
' Replace the slected text with corrected text
TextProjectDesc.Text = strResult
End Sub
Bookmarks