help with paragraph identification

C

Cindy M -WordMVP-

Hi Ajmilton,
Well, if it isn't one thing, it's always something else.
This insertion/style stuff with range worked quite well, but your
recommendation earlier to use the \! switch to remove the hidden
format from the STYLEREF field isn't working. I searched some and
found the \*charformat switch, tried it, searched some more and found
out that \*charformat seems to not work in styleref.
Any ideas why the \! switch doesn't work either?
My brain must have really been on vacation. I apologize abjectly for
sending you off in the wrong direction. CharFormat and not \! for this.
And <kicking myself> it really isn't working with the hidden text
format.

But I have found another approach (and tested it just to make sure my
brain wasn't playing tricks on me, again!) that will do what you need.
Actually, given your requirements, you might even prefer it. I'm gong to
describe it to you, but would be happy to email you the sample/test file
I set up, if you wish.

1. Word has a construct known as a FRAME. This is similar to a text box,
but is recognized as being part of the STORY to which it's anchored (as
opposed to being in the Drawing Layer).

2. Frames can be positioned anywhere on the page (i.e. also in the
margins)

3. Frames can be part of a paragraph STYLE.

4. So, I created a style with these basic characteristics
- white font color
- containing a frame
- .01 cm wide
- .01 cm high
- no border
- set to "Move with text" (so that it stays with the paragraph)

5. Format the info for the header with this style, and StyleRef the
style, with the \* CharFormat switch.

6. Use code like this to insert the text (in its own paragraph) and
format it with the frame style.

Dim rng As Word.Range

Set rng = Selection.Range.Paragraphs(1).Range
rng.Collapse wdCollapseStart
rng.InsertBefore vbCr
rng.Collapse wdCollapseStart
rng.Text = "Level 1, 2nd instance"
rng.Style = FrameStyleName

On another note, I'm thinking about repaginating the document before
applying styles so I don't have to worry about paragraphs split across
pages. I haven't started looking at this idea yet, but if there's a
straightfoward way to check for a paragraph breaking across a page,
I'd appreciate some direction toward that as well.
If you don't want any paragraphs breaking across pages, make sure
they're all formatted with "Keep lines together".

Otherwise, the way I'd check would be to compare the
.Information(wdActiveEndPageNumber) for the start and end ranges of the
paragraph range. I'd probably set up a range.Duplicate to the
paragraph.range, then collapse it one direction; set it again and
collapse in the other direction. (I've found that to be faster, in a
long document, than calculating the .Start and .End characters).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
A

ajmilton

Cindy M -WordMVP- said:
Hi Ajmilton,
But I have found another approach (and tested it just to make sure my
brain wasn't playing tricks on me, again!) that will do what you need.
Actually, given your requirements, you might even prefer it. I'm gong to
describe it to you, but would be happy to email you the sample/test file
I set up, if you wish.
<snip>

I'm going to give it a whirl with your suggestions, but I'd definitely
like to see your test as well.

thanks
-aj
 

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