Consulting

Results 1 to 3 of 3

Thread: Solved: prompt user to spell check when document is closed

  1. #1

    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]

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    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]
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    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
  •