You can find detailed answer for each MS Office program at
MS Office Support: The spelling and grammar checker isn't working as expected:
In Office 2010, Office 2013, and Office 2016
- Select the text that you want the spelling and grammar checker to ignore.
- On the Review tab, in the Language group, click Language, and then click Set Proofing Language.
- Select the Do not check spelling or grammar check box.
In Office 2007
- Select the text that you want the spelling and grammar checker to ignore.
- Open the Language dialog box:
- In Word: On the Review tab, in the Proofing group, click Set Language.
- In Outlook: In the Spelling drop-down list, in the Proofing group, click Set Language.
- In PowerPoint: On the Review tab, in the Proofing group, click Language.
- Select the Do not check spelling or grammar check box.
After selecting Do not check spelling or grammar check box, I've found very useful the option to create a new style from selection:
In Word 2010, you can create a special style that is based on the
selected text:
Right-click the selection, and then click Save Selection as a New Quick Style.
Give the style a name—for example, code—and then click OK.
Notice that if you don't find the New Quick Style in the context menu, you can find it under Sytles as "Save Selection as new Quick Style..."
After that, you can give that Style to all portions of text you don't want to be checked.