B
Bart
I have created a form that allows my user to type in a
text box and run a spell-check and grammar check using
WORD. My problem is that it opens a word document after
running the spell-check and grammar check. I would really
like it to not open the word document at all but I have
been unsuccessful in getting it to programmatically close
the word document. I would appreciate any advice.
'The following code runs a spell check and grammar check
Private Sub cmdSpellCheck_Click()
Dim oWDBasic As Object
Dim sTmpString As String
Set oWDBasic = CreateObject("Word.Basic")
oWDBasic.FileNew
txtFreeForm.SetFocus
oWDBasic.Insert txtFreeForm.Text
On Error Resume Next
oWDBasic.ToolsSpelling
oWDBasic.ToolsGrammar
oWDBasic.EditSelectAll
oWDBasic.SetDocumentVar "MyVar", WDBasic.Selection
sTmpString = oWDBasic.GetDocumentVar("MyVar")
'The following code will NOT close WORD
'DoCmd.Close acModule, "word.basic", acSaveNo
'DoCmd.Close , "word.basic", acSaveNo
'DoCmd.Close , oWDBasic, acSaveNo
'oWDBasic.Quit
txtFreeForm.Text = Left(sTmpString,Len(sTmpString) - 1)
MsgBox "The spell check and grammar check are complete"
End Sub
Private Sub cmdOk_Click()
txtFreeForm.SetFocus
gstrFreeForm = txtFreeForm.Text
If IsNull(txtFreeForm) Then
MsgBox "You must type something in the text box"
Else
DoCmd.Close
End If
End Sub
text box and run a spell-check and grammar check using
WORD. My problem is that it opens a word document after
running the spell-check and grammar check. I would really
like it to not open the word document at all but I have
been unsuccessful in getting it to programmatically close
the word document. I would appreciate any advice.
'The following code runs a spell check and grammar check
Private Sub cmdSpellCheck_Click()
Dim oWDBasic As Object
Dim sTmpString As String
Set oWDBasic = CreateObject("Word.Basic")
oWDBasic.FileNew
txtFreeForm.SetFocus
oWDBasic.Insert txtFreeForm.Text
On Error Resume Next
oWDBasic.ToolsSpelling
oWDBasic.ToolsGrammar
oWDBasic.EditSelectAll
oWDBasic.SetDocumentVar "MyVar", WDBasic.Selection
sTmpString = oWDBasic.GetDocumentVar("MyVar")
'The following code will NOT close WORD
'DoCmd.Close acModule, "word.basic", acSaveNo
'DoCmd.Close , "word.basic", acSaveNo
'DoCmd.Close , oWDBasic, acSaveNo
'oWDBasic.Quit
txtFreeForm.Text = Left(sTmpString,Len(sTmpString) - 1)
MsgBox "The spell check and grammar check are complete"
End Sub
Private Sub cmdOk_Click()
txtFreeForm.SetFocus
gstrFreeForm = txtFreeForm.Text
If IsNull(txtFreeForm) Then
MsgBox "You must type something in the text box"
Else
DoCmd.Close
End If
End Sub