For once I'm trying to write a technical document in Microsoft Word 2013 and I need to add some code snippets from time to time. I copy the code from Microsoft SQL Server Management Studio and paste it onto Word, which preservers the code highlighting. So far so good.

Now, I've created a paragraph style with, basically, just a background color and a border. The color of the font should be preserved (it's set to Automatic) but it does not work.

When I apply the style to the paragraph, most of it turns black. Yep, most of it, some parts of it, look at the before and after:

Before and after

Why?? Why does that happen? Why the red stays, but the blue goes away?


From your description, it seems that this is all a single paragraph with soft line breaks. To check (Word 2010, but should work in 2013 as well), turn on Show all, which is the paragraph mark button on the home tab (I don't remember which group). A soft line break will show up as a bent arrow pointing down and left, while a paragraph break will show up as a paragraph mark.

If it is all one paragraph, what you're experiencing is Word's designed behavior. Word assumes any direct character formatting applied to more than half of a paragraph (the blue color, in this case) is the "normal" character format of the paragraph. When you apply the style, it overwrites the normal format with whatever is in the style. The red and black are treated as exceptions, so they're left alone.

A couple of possible solutions:

  • Paste the code into Word, copy everything except the paragraph mark at the end (easiest if Show all is turned on), and paste into a blank paragraph that already has the desired style applied. This should keep the direct formatting (although reapplying the style will change the blue to black).

  • Paste directly from the Server Management Studio into a paragraph that already has the desired paragraph style. I suspect this one won't work (you're probably pasting in a whole paragraph, with its own paragraph formatting), but it's worth a try.

  • Create and apply character styles for the colors before applying the paragraph style. This is a little more work to set up, but applying a paragraph style shouldn't overwrite any formatting applied through character styles.

  • Just live with it and reapply the colors manually. This is definitely not an ideal solution, but with Word the simplest option is often to let the program do whatever it wants and then clean things up when it isn't looking.

If this isn't all one paragraph, then I don't know what's causing it. Word is weird sometimes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.