Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Auto spell check before print or send? (97 - all?)

    I have a colleague at work (no, not me, although it could be) who has enabled check spelling while typing yet he always ignores the little red lines when he prints. Is there any way to cause the spell checker to be invoked when he selects print or send from the FILE menu or when he clicks on the print icon? I have searched for forum and did not find any such solution.

  2. #2
    Star Lounger
    Join Date
    Jul 2006
    Location
    Colorado, USA
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto spell check before print or send? (97 - all?)

    One possibility would be to trap the _DocumentBeforePrint in the Normal template.

    Open up the VB code window with Alt-F11
    Right click on Normal and select Insert > Class Module
    Rename the Class from Class1 to something like PrintClass by changing the (Name) in the Properties Window below the Project Window
    In that new class module code window add a WithEvents declaration:

    Public WithEvents appWord As Word.Application

    Below that add an event handler to trap the print:

    Private Sub appWord_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
    ActiveDocument.CheckSpelling
    End Sub

    Back in the Normal Modules, in the NewMacros code window, create a sub called AutoExec if there is not one already. Add the following code to it:

    Sub AutoExec()
    Set appWord.appWord = Word.Application
    End Sub

    Add the following to the top of the NewMacros window:

    Dim appWord As New PrintClass

    Exit Word. This is an AutoExec macro, so be careful. It should bring up the spell check before any print commands.

    I'm sure if Hans was here, he could give a more easy method, but this is all I can think of.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Auto spell check before print or send? (97+)

    By creating a macro with the same "name" as a menu command, such as FilePrint or FilePrintDefault (the button that bypasses the dialog), you can run your own code when the user invokes that command. However, you might give a choice, such as:

    <code>Sub FilePrint()
    If MsgBox("Spell check before printing?", vbQuestion + vbYesNo) = vbYes Then
    ActiveDocument.CheckSpelling
    End If
    Dialogs(wdDialogFilePrint).Show
    End Sub

    Sub FilePrintDefault()
    If MsgBox("Spell check before printing?", vbQuestion + vbYesNo) = vbYes Then
    ActiveDocument.CheckSpelling
    End If
    ActiveDocument.PrintOut
    End Sub</code>

    These can be placed in the user's Normal.dot template for convenience, or distributed as part of a global template in the WordStartup folder, or in a COM Add-in. Note that unlike the suggestion above, the user cannot stop the print process by choosing to spell check first, so if that capability is necessary, this simple approach might not be enough.

    As for "File>Send", I am not immediately familiar with how to hook in to that.

  4. #4
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto spell check before print or send? (97+)

    Thank you both for the information. Very very useful... this should eliminate a lot of "Why didn't you spell check this document???" questions and comments.

  5. #5
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto spell check before print or send? (97+)

    This is not going to work if the document is protected for forms and the cursor is in a FormFiled in a protected section. To work around that, you could test that and, if necessary, skip protected sections.

    <font face="Georgia">Sub FilePrint()
    If MsgBox("Spell check before printing?", vbQuestion + vbYesNo) = vbYes Then
    If ActiveDocument.ProtectionType <> wdNoProtection Then
    Dim i As Integer
    For i = 1 To ActiveDocument.Sections.Count
    If ActiveDocument.Sections(i).ProtectedForForms = False Then
    ActiveDocument.Sections(i).Range.CheckSpelling
    End If
    Next i
    Else
    ActiveDocument.CheckSpelling
    End If
    End If
    Dialogs(wdDialogFilePrint).Show
    End Sub</font face=georgia>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •