I asked this question in the Microsoft Office Forum, but then found the answer myself. That made it seem like a Superuser question!
As a Software Developer, I am frequently creating documents which include parts of computer programs. Naturally, computer programs are not written in English, so such code contains what appear to be spelling errors. When I include an entire section of code, I can create a "Code" style which not only formats using a fixed-width font like "Consolas", but it also turns off spell checking for the text with that style.
This doesn't help me when I include code in the middle of an English sentence. For instance:
- At this point in the program flow, the getSomethingForMe function is called.
I would really like to be able to create a style which would turn off spell checking just for the "code" text, and not for the entire document. Can I do so?
Here's what I tried:
- Create a new document
- Enter two lines of text, one spelled correctly, one with every word misspelled.
- Select the first word of the first line
- Click "Styles" in the pop-up toolbar
- Click "Create a style"
- Accept the defaults (Name="Style1"), but then click "Modify"
- Change the "Style type" to "Character"
- Click the "Format" drop down button at the bottom and choose "Language"
- (The "do not check spelling or grammar check box is filled-in-selected)
- Click the "Do not check spelling or grammar" checkbox, then click ok
- Click "Ok" to the "Create new style from formatting" dialog
- Select the first (misspelled) word of the second line
- Click "Styles" in the pop-up toolbar
- Click "Apply styles"
- Select "Style1" from the drop down
- Click "Reapply"
- Close the "Apply Styles" pop-up
The misspelled word is now in the "Style1" style, but is still flagged with a squiggly red line.
Clicking "Apply styles" again, and then "Modify", shows that the "Do not check spelling or grammar" checkbox is still filled-in-selected.
In other words, the language setting didn't "take".
This is what I remember that I used to be able to do with older versions of Word. For some reason, I can't get it to work now.