Copy all possible misspelled words (wavy red underline) to the end ofthe document.

A

andreas

Dear Experts:

MS Word checks spelling by using wavy red underlines to indicate
possible misspelling. Is it possible to have all these words - that
have been underlined wavy red - copied to a new document or the end of
the current document.

Help is much appreciated. Thank you very much in advance. Regards,
Andreas
 
G

Graham Mayor

Maybe something along the lines of

Dim sWord As String
Dim oSource As Document
Dim oTarget As Document
Set oSource = ActiveDocument
Set oTarget = Documents.Add
For i = 1 To oSource.Words.Count
sWord = oSource.Words(i)
If CheckSpelling(sWord, IgnoreUppercase:=False) = False Then
oTarget.Range.InsertAfter sWord & vbCr
End If
Next i
With oTarget
.Range.End = .Range.End - 1
.Range.Sort
.Paragraphs(1).Range.Delete
.Activate
End With

It will take a while to run!
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

andreas

Maybe something along the lines of

Dim sWord As String
Dim oSource As Document
Dim oTarget As Document
Set oSource = ActiveDocument
Set oTarget = Documents.Add
For i = 1 To oSource.Words.Count
    sWord = oSource.Words(i)
    If CheckSpelling(sWord, IgnoreUppercase:=False) = False Then
        oTarget.Range.InsertAfter sWord & vbCr
    End If
Next i
With oTarget
    .Range.End = .Range.End - 1
    .Range.Sort
    .Paragraphs(1).Range.Delete
    .Activate
End With

It will take a while to run!
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>






- Show quoted text -

Hi Graham,

great coding. Thank you so much. Exactly what I wanted, although there
is one thing that would make this code even better. Is it possible to
list the respective page number of the misspelled word as well?

Regards, Andreas
 
G

Greg Maxey

Try:

Sub ScratchMacro()
Dim oMisSpelledWord As Word.Range
Dim oSource As Document
Dim oTarget As Document
Set oSource = ActiveDocument
Set oTarget = Documents.Add
oTarget.Range.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderDots
For Each oMisSpelledWord In oSource.Range.SpellingErrors
oTarget.Range.InsertAfter oMisSpelledWord & vbTab & _
oMisSpelledWord.Information(wdActiveEndPageNumber) & vbCr
Next
With oTarget
.Range.End = .Range.End - 1
.Range.Sort
.Paragraphs(1).Range.Delete
.Activate
End With
End Sub

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org



Maybe something along the lines of

Dim sWord As String
Dim oSource As Document
Dim oTarget As Document
Set oSource = ActiveDocument
Set oTarget = Documents.Add
For i = 1 To oSource.Words.Count
sWord = oSource.Words(i)
If CheckSpelling(sWord, IgnoreUppercase:=False) = False Then
oTarget.Range.InsertAfter sWord & vbCr
End If
Next i
With oTarget
.Range.End = .Range.End - 1
.Range.Sort
.Paragraphs(1).Range.Delete
.Activate
End With

It will take a while to run!
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>






- Show quoted text -

Hi Graham,

great coding. Thank you so much. Exactly what I wanted, although there
is one thing that would make this code even better. Is it possible to
list the respective page number of the misspelled word as well?

Regards, Andreas
 
G

Greg Maxey

Graham,

This isn't working on my end. This line throws an error:

If CheckSpelling(sWord, IgnoreUppercase:=False) = False Then

Says it is looking for a function.
 
G

Greg Maxey

Andreas,

Just polishing the cannon ball:

Sub ScratchMacro()
Dim oMisSpelledWord As Word.Range
Dim oSource As Document
Dim oTarget As Document
Set oSource = ActiveDocument
Set oTarget = Documents.Add
Dim oSortRng As Word.Range
With oTarget.Range
.Paragraphs(1).Range.Style = "Title"
.Paragraphs(1).Range.Text = "List of Spelling Errors In " & oSource.Name
.InsertAfter vbCr
.Paragraphs(2).Range.Style = "Normal"
.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6.5), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderDots
For Each oMisSpelledWord In oSource.Range.SpellingErrors
.InsertAfter oMisSpelledWord & vbTab & _
oMisSpelledWord.Information(wdActiveEndPageNumber) & vbCr
Next
End With
With oTarget
Set oSortRng = .Range
oSortRng.Start = .Paragraphs(2).Range.Start
oSortRng.End = .Range.End - 1
oSortRng.Sort
.Activate
.Paragraphs.Last.Range.Delete
End With
End Sub
 
A

andreas

Andreas,

Just polishing the cannon ball:

Sub ScratchMacro()
Dim oMisSpelledWord As Word.Range
Dim oSource As Document
Dim oTarget As Document
Set oSource = ActiveDocument
Set oTarget = Documents.Add
Dim oSortRng As Word.Range
With oTarget.Range
  .Paragraphs(1).Range.Style = "Title"
  .Paragraphs(1).Range.Text = "List of Spelling Errors In " & oSource..Name
  .InsertAfter vbCr
  .Paragraphs(2).Range.Style = "Normal"
  .ParagraphFormat.TabStops.Add Position:=InchesToPoints(6.5), _
     Alignment:=wdAlignTabRight, Leader:=wdTabLeaderDots
  For Each oMisSpelledWord In oSource.Range.SpellingErrors
    .InsertAfter oMisSpelledWord & vbTab & _
       oMisSpelledWord.Information(wdActiveEndPageNumber) & vbCr
  Next
End With
With oTarget
   Set oSortRng = .Range
   oSortRng.Start = .Paragraphs(2).Range.Start
   oSortRng.End = .Range.End - 1
   oSortRng.Sort
   .Activate
   .Paragraphs.Last.Range.Delete
End With
End Sub









--
Greg Maxey -  Word MVP

My web sitehttp://gregmaxey.mvps.org
Word MVP web sitehttp://word.mvps.org- Hide quoted text -

- Show quoted text -

Hi Greg,

what a nice code! You really deserve this Word MVP designation. Thank
you so much for your terrific help. I really appreciate it.
Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top