-
Solved: prompt user to spell check when document is closed
I have some very simple VBA code below. One macro runs automatically when the document opens and the other runs automatically when the document is closed. The first sets the spell check property to False to indicate that spell check has not been run. When the document closes the message box should show that spell check has not been run "False" but instead it always switches it to True to indicate that spell check has been run. I want to prompt users when they close the document and ask if they ran spell check but I don't want to ask them if they already ran spell check.
[VBA]Sub AutoOpen()
Application.ResetIgnoreAll
ActiveDocument.SpellingChecked = False
ActiveDocument.GrammarChecked = False
End Sub
Sub AutoClose()
Dim boSpellingChecked As Boolean
boSpellingChecked = ActiveDocument.SpellingChecked
MsgBox boSpellingChecked
End Sub[/VBA]
-
You would need to turnoff the option Check Spelling as you type for that code to work. I suggest this instead:
[VBA]Sub AutoClose()
If ActiveDocument.SpellingErrors.Count > 0 Then
If MsgBox("Your document contains one or more spelling errors." _
& " Do you want to run the spelling checker?", vbQuestion + vbYesNo, _
"Spelling Errors Detected") = vbYes Then
ActiveDocument.CheckSpelling
End If
End If
End Sub
[/VBA]
-
gmaxey ROCKS!!!! Thank you sooo much. Your solution works perfectly. Thanks for teaching me something new.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules