« Bon Anniversaire! | Main | New Article on Microsoft at Work! (Office) »
Happy Tuesday everybody! I received an email about a problem document in which a bunch of numbered paragraphs appeared combined into a single paragraph -- but only in print preview or when printed, not on screen. Thought the answer might be of interest to others, so it felt like a blog post (yes, I know I still owe other topics I've promised to blog on -- but this was a direct question ... so it takes priority :)
The answer, as you might suspect, is that the paragraph marks had the hidden font attribute applied to them. So, why does this happen and what can you do about it? If this has happened to you, here's the scoop...
Using hidden paragraph marks as a TOC workaround
Applying hidden font formatting to a paragraph mark is an old workaround for run-in headings that need to be included in a TOC. For example ... if I have a paragraph:
Sample heading Sample text. Sample text. Sample text. Sample text. Sample text. Sample text. Sample text. Sample text. Sample text. Sample text.
... let's say that I only want the text "Sample heading" to be included in the TOC, but I'm generating the TOC from styles.
Well, if you know about the style separator, you can insert that between the heading and the rest of the text. (The style separator is actually just a hidden paragraph mark that's controlled so that it won't mess with your other formatting.)
But, if you don't know about it (which most Word users don't -- it's not on any menu or toolbar by default, though there is a shorcut key assigned to it by default) and you need that same text in the TOC, you might have typed "Sample heading" as a separate paragraph and hidden it's paragraph mark, so that it appeared to be a run-in paragraph in the document, but still generated correctly in the TOC.
The problem
As you probably know, all paragraph formatting is stored in the paragraph mark that falls at the end of a paragraph. For this reason, when you press ENTER to start a new paragraph, you get the same formatting (by default) as you had in the preceding paragraph. That is, all formatting stored in the paragraph mark carries over to the new paragraph unless you change it (or specify otherwise by using styles and setting Style for the Following Paragraph to be something other than the same style).
In the case of applying the hidden font attribute directly to a paragraph mark, that formatting will be retained when you press ENTER unless you remove it, because direct font formatting will take precedence even over a paragraph style. Word thinks if you've applied it, you did so deliberately (technology, no matter how good, can't read your mind after all ;-)
So, when a document gets edited by lots of people, or copied and changed and reused over time ... it's not unlikely that one person in the mix had used this workaround at some point ... and someone else carried that formatting accidentally (and unknowingly) to other paragraphs just by pressing ENTER to add new content.
How can you fix it?
Just select each affected paragraph mark and remove the hidden attribute (available in the Font dialog box on the Format menu). The fellow who wrote to me smartly recommended to his users to use the Find and Replace feature to locate instances of hidden text. You can even do that in one step and let it do the work for you in a simple Replace All function (if, that is, you want to remove hidden text from any paragraph mark in the document -- otherwise, use Replace and let the Find and Replace feature take you to each instance, so that you can can confirm).
To do this, set up the Replace dialog box so that you are searching for paragraph marks with the hidden font attribute and replacing with "Find what text" with "Not hidden" as the formatting attribute. This is what your dialog box will look like:

You can type the paragraph mark reference as well as the "Find what text" replacement reference as you see here, or insert them from the Special menu you see in this dialog box ... Set both 'hidden' and 'not hidden' in the Font dialog box available from the Format menu in this dialog box (see both Special and Format at the bottom of the dialog box after you click MORE to expand the dialog box).
IMPORTANT: If you have intentionally used the style separator in the document, do NOT use Replace All -- as this setup will find and remove the hidden attribute from those marks as well. In that case, use Replace and confirm at each mark that you want to change.
What's this style separator you keep talking about?
If you've never seen the Style Separator, you can add it to a menu, toolbar, or keyboard shortcut yourself. It does the same thing for generating a TOC from the styles applied to run in headings as you do with hidden text, but it doesn't mess with your formatting or get carried from one paragraph to the next. To get it, go to Tools, Customize, Commands. You'll see Insert Style Separator in the All Commands list ... drag it to the toolbar or menu of your choice ... It is also already assigned (by default) to keyboard shortcut ALT+CTRL+ENTER.
Insert the style separator at the end of the run-in heading to start a new paragraph without the appearance of a new paragraph (you can use a separate style). Note that, if you insert a style separator in an existing paragraph -- it will turn the existing paragraph mark into the style separator (as mentioned above, it's really just a controlled hidden paragraph mark)... so be sure that you're working with all formatting marks visible, and pay attention to what you insert in the document.
If this post raised or left any questions on the topic ... post a comment and I'll reply as quickly as I can -
Have a great day!
Posted by Stephanie
TrackBack URL for this entry:
http://www.arouet.net/cgi-bin/mt/mt-tb.cgi/139
Thanks for signing in, . Now you can comment. (sign out)
(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)
Comments
I was trying to create a macro in VBA a month ago to insert the Style Separator throughout my document, but have been unable to create one that loops. Here is my macro:
Sub StyleSep()
'
' Test Macro
' Find H2U style, cursor right, the insert Style Separator
'
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.StyleS("Hdng2underline")
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Application.Run MacroName:="NewMacros.RunStyleSeparator"
End Sub
-------
This is a legal document that has styles attached to numbered headings. The run-in headings get formatted (underlined) using the "Hdng2underline" style (it is a Character style), then the Style Separator is inserted using the firm's "RunStyleSeparator" (it didn't work using Word's built-in one). When I try a loop macro it either loops forever, or plain, ol' doesn't work. Any suggestions? Thx.
Posted by: Alice | November 23, 2005 06:01 PM
Hi, Alice,
Using Replace isn't often the easiest way to loop through a document in my experience. There are definitely times when you need to use that feature -- but when they'll work for what you need, a For Each or Do loop can usually do the trick much easier.
As it happens, if you look up the InsertStyleSeparator method in Word VBA help, the example provided (that you can cut and paste into your module to try out) is to add style separators wherever a given style exists throughout the document -- and it does so using a Do loop.
I think a For Each...Next loop is even easier, and it's even less code. give this a try and let me know how it goes (just used Heading 1 as an example style, of course) ... notice that you don't need to position the cursor, as the style separator will always appear at the end of the selected paragraph):
Sub InsStySep()
Dim apr As Paragraph
For Each apr In ActiveDocument.Paragraphs
If apr.Style = "Heading 1" Then
apr.Range.Select
Selection.InsertStyleSeparator
End If
Next
End Sub
Happy holidays!
Steph
Posted by: Stephanie | November 23, 2005 08:02 PM