Problem with a macro

Copper Contributor

Hi. Mac OSX. Microsoft 16.66.1 (22101101)

A macro I was using in the past is sometimes giving problems, like a compile error.
See screenshot below.

Please, let me fix it or have another one.


The macro is this:

Sub ListSpellingErrors()
    Dim inDoc As Document
    Dim outDoc As Document
    Dim er As Range
    Set inDoc = ActiveDocument
    If ActiveDocument.SpellingErrors.Count > 0 Then
        Set outDoc = Documents.Add
        outDoc.Sections(1).Headers(wdHeaderFooterPrimary) _
            .Range.Text = "Spelling errors in " & inDoc.FullName
        MsgBox "There are no spelling errors in this document."
        Exit Sub
    End If
    For Each er In inDoc.SpellingErrors
        outDoc.Range.InsertAfter er.Text & vbCr
    Next er
    ' optionally, to sort the output,
    ' remove the quote mark from the next line
'    outDoc.Range.Sort
End Sub


0 Replies