Nicholas_Zgb
Nicholas_Zgb

Reputation: 1

Autocorrect Word 2010 (VBA)

For my problem I tried different things and none worked: I am flexible about the way to actually solve it, so I think it's best to begin with the purpose.

I get long word files and I need to do some quality checks and proofreading. There are a lot of words in the file that are not capitalized correctly. I want to get this in automatic (no a normal grammar software/add-on won't do)

I have all the entries in my auto correct file, in word files (quite huge better not use them) and in an excel spreadsheet (wrong entry - correct entry).

Refreshing the document doesn't do the trick. If I pick a word from the list and select it and press the space-bar then it gets changed so I "wrote" a Macro for that

Sub Try()
    For Each sentence In ActiveDocument.StoryRanges  
        For Each w In sentence.Words            
            Selection.MoveRight Unit:=wdWord, Count:=1
            Selection.TypeText Text:=" "
            Selection.TypeBackspace          
        Next
    Next
End Sub

The thing "worked" i.e. it runs and you can see the cursor speeding through the screen but no words get changed. So I am thinking that Autocorrect get's somehow disabled while Macros are running.. Anyone has a hint? ideally knows a way around it?

Worst case I thought of putting the text in an excel file and writing a macro that for each line of text checks each word against my original list and "if match then substitute" but it doesn't seem too easy (at least for me)

Cheers
I hope that I could explain myself

Upvotes: 0

Views: 493

Answers (1)

SlowLearner
SlowLearner

Reputation: 3294

This Pseudo Code / Outline should get you started:

In Word you can create an instance of Excel and open your spreadsheet:
https://stackoverflow.com/a/24196120/3451115

You can then Loop through your list of WrongWords:
https://stackoverflow.com/a/1463308/3451115

For each WrongWord do a Find and Replace:
VBA to find and replace a text in MS WORD 2010

Upvotes: 1

Related Questions