Word XP Style Separator

M

Matt Reed

Found weird behavior using the style separator.

It may be easiest to just tell you how to recreate the problem rather than
try to explain it, so here goes:

Type a few words than hit Enter, type a few more words, hit Enter again.

Basically you have two paragraphs.

STEP 1) Apply the "Heading 1" style to the first paragraph and leave the
second paragraph as "normal".

STEP 2) Go to the first paragraph and then add the "style separator"
(Ctrl+Alt+Enter).

The two paragraphs combine and I get what looks like one paragraph with two
styles. (Exactly as expected)

STEP 3) Clear all character formatting by selecting all (Ctrl+a) and then
clear formatting (Ctrl+spacebar) that paragraph splits into two parts.
(Exactly as expected)

The document appears to look exactly like at the end of Step 1. Two
paragraphs each with a different style.

Step 4) Try to re-apply the "style separator" as in Step 2 above. -
Nothing happens (maybe a space is added?), still have two paragraphs!

There does seem to be a couple of ways to work around this problem, but they
include deleting the paragraph mark at the end of the first paragraph and
inserting a new on. This can take several steps to get the desired result
and formatting.

Is this supposed to work this way?

I am trying to teach a client's staff on how to use the style separator and
need to know if this is how it is supposed to work of if this is a bug.

Thanks
Matt
 
S

Suzanne S. Barnhill

FWIW, if you create the paragraph as a single paragraph to begin with and
apply the heading style to just the heading portion, Word inserts a style
separator for you. Also, if you want a method that is more
backward-compatible (and less quirky) see
http://home.zebra.net/~sbarnhill/RunInSidehead.htm

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
L

Laura Townsend

Hi Matt,

Myself, I've been underwhelmed w/ the style separator -- My biggest issue
being it seems you have to start by typing the two paragraphs and then use
it, or something like that (I got so annoyed with it I haven't messed with
it in awhile...)

Anyhow, I've written a macro that does what Suzanne's tip sheet talks
about -- you can use it as you're typing along or on paragraphs that are
already typed (by clicking where you want the heading portion to end.)

If you'd like a copy, let me know, I'll email it to you.

Laura
 
M

Matt Reed

Yes I would like to see the macro.

Thanks,

Matt
Laura Townsend said:
Hi Matt,

Myself, I've been underwhelmed w/ the style separator -- My biggest issue
being it seems you have to start by typing the two paragraphs and then use
it, or something like that (I got so annoyed with it I haven't messed with
it in awhile...)

Anyhow, I've written a macro that does what Suzanne's tip sheet talks
about -- you can use it as you're typing along or on paragraphs that are
already typed (by clicking where you want the heading portion to end.)

If you'd like a copy, let me know, I'll email it to you.

Laura
 
L

Laura Townsend

Hi Matt,

Here is the text of the Macro -- it may not be the most elegant method, but
it works... If you put it in a template in your word statrup directory it
will be available when you're in Word. Then you can add a button for it to
a toolbar and/or assign it a keystroke. (I could email it to you in a
template if you don't know how to do all this.)


Sub HiddenPara()
'
'
Dim rngStartHere As Range, rngParaMark As Range
Dim rngStartStyle As Range, CurrStyle As Style
Dim ShowHideStatus As Boolean
Dim iCurScrollPos As Integer

'store user's current show/hide status
iCurScrollPos =
Windows(ActiveDocument).ActivePane.VerticalPercentScrolled
ShowHideStatus = ActiveWindow.ActivePane.View.ShowAll
Application.ScreenUpdating = False

'Turn on show/hide -- paragraphs behave differently w/out it
ActiveWindow.ActivePane.View.ShowAll = True
Selection.Collapse direction:=wdCollapseEnd
Set rngStartHere = Selection.Range
Set rngParaMark = rngStartHere.Duplicate

'turn off show/hide to make sure text is treated as one paragraph
'if there are already hidden paras in it when it expands selection.
ActiveWindow.ActivePane.View.ShowAll = False
Selection.Expand wdParagraph
'remove paragraph mark at end of paragraph from selection.
Selection.MoveEndWhile vbCr, -1
Set rngStartStyle = Selection.Range
rngStartStyle.Collapse direction:=wdCollapseStart
Set CurrStyle = rngStartStyle.ParagraphFormat.Style
'turn back on show hide so hidden paragraph marks can be found
'remove any pre-existing hidden paragraph marks
ActiveWindow.ActivePane.View.ShowAll = True
Selection.Find.ClearFormatting
Selection.Find.Font.Hidden = True
Selection.Find.Font.Bold = True
Selection.Find.Font.Color = wdColorDarkBlue
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Collapse direction:=wdCollapseStart
Selection.ParagraphFormat.Style = CurrStyle

'Insert a hidden paragraph mark at original insertion point.
'make it dark blue to distinguish it.
rngParaMark.InsertParagraphAfter
With rngParaMark.Font
.Hidden = True
.Bold = True
.Color = wdColorDarkBlue
End With
'Apply body text to the paragraph after the insertion point.
Set rngParaMark = rngParaMark.Next(wdParagraph, 1)
rngParaMark.Style = ActiveDocument.Styles("Body Text")
With rngStartHere
.MoveEnd Unit:=wdCharacter, Count:=1
.Collapse direction:=wdCollapseEnd
.Select
End With
ActiveWindow.ActivePane.View.ShowAll = ShowHideStatus
Application.ScreenUpdating = True
Windows(ActiveDocument).ActivePane.VerticalPercentScrolled = iCurScrollPos
End Sub
 
B

Bob S

Found weird behavior using the style separator.

It may be easiest to just tell you how to recreate the problem rather than
try to explain it, so here goes:

Type a few words than hit Enter, type a few more words, hit Enter again.

Basically you have two paragraphs.

STEP 1) Apply the "Heading 1" style to the first paragraph and leave the
second paragraph as "normal".

STEP 2) Go to the first paragraph and then add the "style separator"
(Ctrl+Alt+Enter).

The two paragraphs combine and I get what looks like one paragraph with two
styles. (Exactly as expected)

STEP 3) Clear all character formatting by selecting all (Ctrl+a) and then
clear formatting (Ctrl+spacebar) that paragraph splits into two parts.
(Exactly as expected)

The document appears to look exactly like at the end of Step 1. Two
paragraphs each with a different style.

Step 4) Try to re-apply the "style separator" as in Step 2 above. -
Nothing happens (maybe a space is added?), still have two paragraphs!

There does seem to be a couple of ways to work around this problem, but they
include deleting the paragraph mark at the end of the first paragraph and
inserting a new on. This can take several steps to get the desired result
and formatting.

Is this supposed to work this way?

I am trying to teach a client's staff on how to use the style separator and
need to know if this is how it is supposed to work of if this is a bug.

Thanks
Matt


First, notice that after step 4 you really have combined the
paragraphs. Turn off showing paragraph marks and you should see it.
The space character was added by the code that automatically fixes
space when you cut, paste, or otherwise muck about.

Here's my guess as to what is going on...

A "style separator" is not exactly a hidden paragraph mark, but is
slightly different. (Notice that when you show paragraph marks a style
separator shows up as an odd paragraph mark and does not split the
"paragraph", but a hidden paragraph mark looks normal and does split
the "paragraph". QED)

When you did CTRL+Spacebar, you cleared the "hidden" flag but did not
change some other piece of internal state. (This is a bug. It should
either do nothing or convert it back to a normal mark.) The paragraph
mark is now in an inconsistent state; part of it says "style
separator" but it is not hidden.

Then when you tried to re-insert the style separator you toggled some
more state starting from an inconsistent state, and you got strange
results. (You probably toggled the "style separator mark" off and
hidden on, which would account for the results that you see.)

Bob S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top