I'm going out of town for the weekend, so if anyone has any questions I will answer them on Monday. Sorry if that inconvenciences anyone! (although I have a feeling that everyone else is gone for the weekend too)
Main Topics
Browse All TopicsI need to write a Macro that will do the following:
1. Take a specified file whose name is the format <base>.in.txt, e.g. "text.in.txt"
2. Spell check it
3. Replace each misspelled word with the top correction suggested by the spell checker. If there are no suggestions, leave word as is.
4. Save result into the file <base>.out.txt, i.e. "text.out.txt"
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: Kelly_in_Los_AngelesPosted on 2004-09-03 at 15:32:03ID: 11977901
Hi ilyaz,
Save()
r & myFileName)
>= 1
oc.Spellin gErrors(1) .Text)
xt = SpellSuggs(1) Proofing = True
Will the following work for you?
I'm pretty sure you have an understanding of the code, so I will assume that my code commentary within the macro will serve as a sufficient explanation.
On the other hand, if you have questions about any of it, then of course you are more than welcome to ask me right away and I will answer tout de suite!
Sub Auto_Spell_and_Rename_and_
Dim InWhatFolder As String
Dim FileNameEnding As String
Dim SaveNameEnding As String
Dim mySearchString As String
Dim myFileName As String
Dim myDoc As Document
Dim SpellSuggs As SpellingSuggestions
Dim mySaveName As String
'******** YOU MUST PERSONALIZE THE FOLLOWING THREE STRING VALUES ****
InWhatFolder = "C:\My txt files\"
FileNameEnding = ".in.txt"
SaveNameEnding = ".out.txt"
mySearchString = InWhatFolder & "*" & FileNameEnding
myFileName = Dir(mySearchString)
If myFileName = "" Then
MsgBox "No files match the criteria: " & mySearchString
End
End If
'If no file matches the file address created by combining InWhatFolder
'with FileNameEnding, then this macro will end RIGHT HERE.
'If we get this far, then at least one file was found
Do
'open the file we found.
Set myDoc = Documents.Open(InWhatFolde
'********* START THE SPELLING CHECK LOOP ********************
Do While myDoc.SpellingErrors.Count
Set SpellSuggs = GetSpellingSuggestions(myD
If SpellSuggs.Count >= 1 Then
myDoc.SpellingErrors(1).Te
Else
myDoc.SpellingErrors(1).No
End If
Loop
'********* END THE SPELLING CHECK LOOP ***********************
mySaveName = Left(myFileName, Len(myFileName) - Len(FileNameEnding)) _
& SaveNameEnding
'************ SAVE WITH A NEW NAME AND CLOSE THE DOCUMENT ************
myDoc.SaveAs InWhatFolder & mySaveName, wdFormatText
myDoc.Close
Set myDoc = Nothing
myFileName = Dir()
'Loop to the next file we find, unless none is found
Loop While myFileName <> ""
End Sub