Re: help with paragraph identification

From: Cindy M -WordMVP- (C.Meister-C_at_hispeed.ch)
Date: 06/25/04


Date: Fri, 25 Jun 2004 17:22:58 +0200

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 :-)



Relevant Pages

  • Re: anchoring a frame but not to a header
    ... However as long as you don't have the anchor locked you ... can drag it to anchor the frame to any paragraph on the same page. ... What I was indicating is that if you select a Picture the Format Menu ...
    (microsoft.public.word.drawing.graphics)
  • Re: anchoring a frame but not to a header
    ... different page than its anchor paragraph. ... the frame will move to the bottom of *that* page. ... What I was indicating is that if you select a Picture the Format Menu ...
    (microsoft.public.word.drawing.graphics)
  • Re: anchoring a frame but not to a header
    ... Position a frame ... a reference point, such as a paragraph, page, margin, or newspaper column. ... Obviously I've locked the anchor. ... What I was indicating is that if you select a Picture the Format Menu will ...
    (microsoft.public.word.drawing.graphics)
  • Re: New Style with Dropcap character
    ... Drop caps are created using frames, and, although ... frame encloses the entire paragraph. ... of the first chapter and do Format | Drop Cap, ...
    (microsoft.public.word.newusers)
  • Re: Frame problem after applying body text style
    ... has a frame as part of its properties. ... In the new window that shows up, click on the dropdown list in the ... I'm using Word for Mac 2004, I recently started using Styles to format ... when I finished writing a paragraph in Normal view (wich ...
    (microsoft.public.mac.office.word)