Microsoft Office Tutorials and References
In Depth Information
Formatting Spelling Errors for Printing
doc.Save¶
'Save the document to be processed¶
'under a different name, but in the same path¶
'so that the original file is not changed.¶
docNewName = GetNewName(doc, NewNameExtension)¶
doc.SaveAs FileName:=doc.Path & docNewName, _¶
AddToRecentFiles:=False¶
'Be sure to start on the first page¶
Selection.HomeKey wdStory¶
Set rng = ActiveDocument.Range¶
'Don't continue if there aren't any¶
'spelling errors¶
If doc.SpellingErrors.Count > 0 Then¶
'If there are lots of errors¶
'in a document, spellcheck doesn't¶
'process well. Break it down, therefore,¶
'and go page by page¶
For pageCounter = 1 To _¶
doc.Range.Information(wdNumberOfPagesInDocument)¶
'In order to place an entire page in a range¶
'use the built in \Page bookmark¶
Set rng = Selection.Bookmarks("\Page").Range¶
For Each spErr In rng.SpellingErrors¶
With spErr¶
'Use the old Word97 command ColorIndex¶
'for the font color so that the macro¶
'runs in all versions¶
If FormatAsColor = True Then _¶
.Font.ColorIndex = wdDarkRed¶
If FormatAsUnderline = True Then _¶
.Font.Underline = wdUnderlineDotDash¶
If FormatAsHighlight = True Then _¶
spErr.HighlightColorIndex = wdGray25¶
If WriteToTable = True Then _¶
TableData = TableData & CStr(pageCounter) _¶
& sepChar & spErr.Text & sepChar _¶
& TrimEndParas(spErr.Sentences(1).Text) & vbCr¶
End With¶
Next spErr¶
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext¶
Next pageCounter¶
If WriteToTable = True Then¶
'Variable declaration¶
Dim rngTable As Word.Range¶
Dim tbl As Word.Table¶
Dim docLogErrors As Word.Document¶
Set docLogErrors = Documents.Add¶
Set rngTable = docLogErrors.Range¶
'Trim off the last paragraph mark¶
TableData = Left(TableData, Len(TableData) - 1)¶
Wrd
Search JabSto ::




Custom Search