Checking for a range of valid styles?

J

JB

Hi Folks,
I'd like to check for valid custom styles in a document based on the
style hierarchy I set e.g. following Heading 1 must be Heading text, A
document cannot end with a style other than EndofDocument etc.

There are Loads more styles than this and trying to code it (My Way)
could be very complicated. My initial thought would be to use a text
file and read an array of acceptable styles that can follow a paragraph
style and cascade it down from there, but this is very messy.

Does anyone have any ideas on how this could be done without using an
external file?


Cheers

J
 
H

Helmut Weber

Hi JB,
I think the key to it could be an elaborate naming of styles,
and the occasional use of the bookmark "headinglevel".
See help for "predefined bookmarks" or whatever it may be in English.
Here are some examples for naming styles, as I am using them
in the production of magazines.
f0-hd-lm ' frame zero = no frame, heading, level main
f0-hd-ls ' frame zero = no frame, heading, level sub
f0-bd-ip ' frame zero = no frame, bodytext, indentation positive
f0-bd-in ' frame zero = no frame, bodytext, indentation negative
f0-bd-i0 ' frame zero = no frame, bodytext, indentation zero
---
f1-hd-lm ' frame 1, heading, level main
f1-hd-ls ' frame 1, heading, level sub
f1-bd-ip ' frame 1, bodytext, indentation positive
if style in selected paragraph = f1-hd-lm then
next style must be f1-hd-ls.
Or still better:
if style in selected paragraph = ??-hd-lm then
next style must be ??-hd-ls.
....
If you got rules for naming styles,
then you don't have to list their names.
I have been working on this for a decade,
including an essential change of the user interface,
so take your time. Some of my users don't even know,
that they are using MS-Word. The disadvantage is,
they blame me for all bugs. ;-)
 
J

JB

Helmut said:
Hi JB,
I think the key to it could be an elaborate naming of styles,
and the occasional use of the bookmark "headinglevel".
See help for "predefined bookmarks" or whatever it may be in English.
Here are some examples for naming styles, as I am using them
in the production of magazines.
f0-hd-lm ' frame zero = no frame, heading, level main
f0-hd-ls ' frame zero = no frame, heading, level sub
f0-bd-ip ' frame zero = no frame, bodytext, indentation positive
f0-bd-in ' frame zero = no frame, bodytext, indentation negative
f0-bd-i0 ' frame zero = no frame, bodytext, indentation zero
---
f1-hd-lm ' frame 1, heading, level main
f1-hd-ls ' frame 1, heading, level sub
f1-bd-ip ' frame 1, bodytext, indentation positive
if style in selected paragraph = f1-hd-lm then
next style must be f1-hd-ls.
Or still better:
if style in selected paragraph = ??-hd-lm then
next style must be ??-hd-ls.
...
If you got rules for naming styles,
then you don't have to list their names.
I have been working on this for a decade,
including an essential change of the user interface,
so take your time. Some of my users don't even know,
that they are using MS-Word. The disadvantage is,
they blame me for all bugs. ;-)
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
Thanks Helmut, Looks very complicated but I think I understand the basic
principle :)

Cheers

J
 
J

JB

Pete said:
My suggestion would be to loo into using a class for checking...

Inside the definition class, you'd have two strings.
StyleBefore
StyleAfter

Then, for each style in your styles defintion list, you'd assign an instance
of that class so that you'd have entries for preceeding and following styles
for each style that you're interested in.

Then, write a function that iterates the paragraphs in the document and uses
the class to check what the style of the preceeding and following paragraphs
are, flagging any that are incorrect.

Pete.


:
Hi Pete,
This sounds good but unfortunately for me I thinks it's outside my skill
level. Do you have an example I could work with/test? or any pointers
as to where I could start?

Cheers

J
 
P

Pete Bennett

J,

Whoops, just re-read your original post and relalised that you need to check
for multiple styles as your before and afters.

Simple enough to modify the code I suggested, simple replace the strings in
the first class with collections and then hold the multiple styles in those
collections. It'll work in pretty much the same way except that you have to
iterate the collections when you do your checking code.

Sorry about that,

Pete
 
J

JB

Pete said:
J,

Whoops, just re-read your original post and relalised that you need to check
for multiple styles as your before and afters.

Simple enough to modify the code I suggested, simple replace the strings in
the first class with collections and then hold the multiple styles in those
collections. It'll work in pretty much the same way except that you have to
iterate the collections when you do your checking code.

Sorry about that,

Pete

:
Wow! Thanks for the effort Pete!

I'll need a couple of days to chew over this and look at collections :)
but I'll let you know how I get on.

Cheers

J
 

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