From: Russ on
Oh, maybe you are asking for field code that will determine the previous
level of the previous paragraph? There is no special field code for that, as
far as I know. You would still have to use VBA to determine the Outline
level and store that in a variable which could be used in a formula field or
If..Then field.

>
> Msgbox selection.paragraphs(1).previous.style
> If the previous paragraph is style Heading 4, then that is what you will see
> in the message box.
>
> And like the link I gave you said:
> Msgbox selection.paragraphs(1).previous.OutlineLevel
> Will show the number 4 for Heading 4.
>
> What's in the field? ALT/F9 will toggle reveal field code or field results.
> I not sure what you mean about no VBA code in the document. Usually you put
> code in a template and open a new document with that template, you don't
> want to mess with another user's Normal.dot setup.
>> That's helpful, but it doesn't answer the question. I want to place a field
>> in bodytext and be able to calculate something based on the Outline Level of
>> the immediately preceding heading. I.e., if the text appears under Heading
>> 1, then x=1; if it appears under a Heading 3, then x=3.
>>
>> So. (1) can you get outline level from a field (I want to avoid VBA code in
>> this document); and (2) how do you find it for the immediately preceding
>> heading when the field is in the body?
>>
>> Thanks.
>> "Russ" wrote:
>>
>>> Read carefully about outline level in this link:
>>> <http://word.mvps.org/FAQs/Numbering/ListString.htm>
>>>
>>>> Is there a way to get the current heading level from a field?
>>>>
>>>> I can't use a StyleRef field because I don't know what style to look for
>>>> (i.e. Heading 1, Heading 2 etc.)
>>>>
>>>> Thanks
>>>>
>>>> (I realize this is the VBA forum)
>>>
>>> --
>>> Russ
>>>
>>> drsmN0SPAMikleAThotmailD0Tcom.INVALID
>>>
>>>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

From: Russ on
"Is there a way to get the current heading level from a field?"

I originally thought you meant that some field was applying a Heading style
and you wanted to know how to find out what Heading style level it was
applying.
Now I see that you meant to create a field to determine the heading style.

> Oh, maybe you are asking for field code that will determine the previous
> level of the previous paragraph? There is no special field code for that, as
> far as I know. You would still have to use VBA to determine the Outline
> level and store that in a variable which could be used in a formula field or
> If..Then field.
>
>>
>> Msgbox selection.paragraphs(1).previous.style
>> If the previous paragraph is style Heading 4, then that is what you will see
>> in the message box.
>>
>> And like the link I gave you said:
>> Msgbox selection.paragraphs(1).previous.OutlineLevel
>> Will show the number 4 for Heading 4.
>>
>> What's in the field? ALT/F9 will toggle reveal field code or field results.
>> I not sure what you mean about no VBA code in the document. Usually you put
>> code in a template and open a new document with that template, you don't
>> want to mess with another user's Normal.dot setup.
>>> That's helpful, but it doesn't answer the question. I want to place a field
>>> in bodytext and be able to calculate something based on the Outline Level of
>>> the immediately preceding heading. I.e., if the text appears under Heading
>>> 1, then x=1; if it appears under a Heading 3, then x=3.
>>>
>>> So. (1) can you get outline level from a field (I want to avoid VBA code in
>>> this document); and (2) how do you find it for the immediately preceding
>>> heading when the field is in the body?
>>>
>>> Thanks.
>>> "Russ" wrote:
>>>
>>>> Read carefully about outline level in this link:
>>>> <http://word.mvps.org/FAQs/Numbering/ListString.htm>
>>>>
>>>>> Is there a way to get the current heading level from a field?
>>>>>
>>>>> I can't use a StyleRef field because I don't know what style to look for
>>>>> (i.e. Heading 1, Heading 2 etc.)
>>>>>
>>>>> Thanks
>>>>>
>>>>> (I realize this is the VBA forum)
>>>>
>>>> --
>>>> Russ
>>>>
>>>> drsmN0SPAMikleAThotmailD0Tcom.INVALID
>>>>
>>>>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

From: Jonathan West on

"automandc" <automandc(a)discussions.microsoft.com> wrote in message
news:B3B0D733-0273-4BFF-A1AE-022DF9FBEECC(a)microsoft.com...
> That's helpful, but it doesn't answer the question. I want to place a
> field
> in bodytext and be able to calculate something based on the Outline Level
> of
> the immediately preceding heading. I.e., if the text appears under
> Heading
> 1, then x=1; if it appears under a Heading 3, then x=3.
>
> So. (1) can you get outline level from a field (I want to avoid VBA code
> in
> this document);

No.

> and (2) how do you find it for the immediately preceding
> heading when the field is in the body?

You can't.

Sorry the answer isn't more positive, but if it really can't be done, all I
can say is "it can't be done"


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup


From: automandc on
Thanks everyone.

By way of explanation, I have a very large document of numbered paragraphs.
I am using Seq fields to apply the numbers.

At the end of every section, I want to leave "reserved" numbers in case I
insert or delete paragraphs, I don't have to renumber the whole document.

I can create a line that says "X to Y is Reserved" where X is the {SEQ \n}
(next number) and the Y is {SEQ \r Z}. I can make Z static (i.e., always
adds 10), and I can even use formulas to make Z always end on a round number
(i.e., I currently have it add between 10 and 19 to get to the next ##9).

I want to be able to vary Z based on the level in the heading outline --
e.g., top level headings will reserve up to the next multiple of 100, 4th
level headings only reserve up to the next multiple of 10. But the only way
to do that is to know what level in the heading outline the current text is
at.

Because many non-sophisticated people will be working in the document, I am
reluctant to use anything that requires code.

I think my workaround will be to add a "tag" to the document based on the
style of the next pargraph using some temporary VBA, and then later I can run
a find/replace to paste in the correct fields based on the type of "tag". I
can either use some reusable code I have to find and replace with a field, or
just put the fields in the clipboard and replace with ^c.

So, thanks for the help. It seems strange that you can't access this info,
since certain fields vary their behavior based on it (e.g., the \h switch in
the SEQ field).

"Jonathan West" wrote:

>
> "automandc" <automandc(a)discussions.microsoft.com> wrote in message
> news:B3B0D733-0273-4BFF-A1AE-022DF9FBEECC(a)microsoft.com...
> > That's helpful, but it doesn't answer the question. I want to place a
> > field
> > in bodytext and be able to calculate something based on the Outline Level
> > of
> > the immediately preceding heading. I.e., if the text appears under
> > Heading
> > 1, then x=1; if it appears under a Heading 3, then x=3.
> >
> > So. (1) can you get outline level from a field (I want to avoid VBA code
> > in
> > this document);
>
> No.
>
> > and (2) how do you find it for the immediately preceding
> > heading when the field is in the body?
>
> You can't.
>
> Sorry the answer isn't more positive, but if it really can't be done, all I
> can say is "it can't be done"
>
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
>
>
>
From: Peter Jamieson on
FWIW, I had a pretty good look around at possible ways to do this with
fields - as you say, the \s switch in SEQ fields obviously knows when to
reset the sequence numbering, but I couldn't think of a way to use that.
Things might be easier if you were able to ensure that there was an
appropriate { SET level n } in every Heading n paragraph which you could
then use in subsequent SEQ fields.

Unfortunately, this is one of those areas where the software designers seem
(presumably accidentally, but when it's as thorough as this it sometimes
seems deliberate) to have closed off every possible way you might conceive
of doing it with fields. For example, an obvious possibility would be to
test the value of { LISTNUM LegalDefault \s 1 } (which should look like
1.1., 1.1.1. etc.) using e.g.

{ IF "{ LISTNUM LegalDefault \s 1 }" = "1.1." "were'at level X" "{ IF
..... }" }

but unfortunately, even if the LISTNUM fields always returned the right
values (and that may depend on very consistent use of heading styles,
outline levels etc.) you do not appear to be able to test the result of a
LISTNUM field (or AUTONUMLGL) or assign it successfully via SET for later
testing.


Peter Jamieson


"automandc" <automandc(a)discussions.microsoft.com> wrote in message
news:1244E90B-4853-458A-B145-C54444122F98(a)microsoft.com...
> Thanks everyone.
>
> By way of explanation, I have a very large document of numbered
> paragraphs.
> I am using Seq fields to apply the numbers.
>
> At the end of every section, I want to leave "reserved" numbers in case I
> insert or delete paragraphs, I don't have to renumber the whole document.
>
> I can create a line that says "X to Y is Reserved" where X is the {SEQ \n}
> (next number) and the Y is {SEQ \r Z}. I can make Z static (i.e., always
> adds 10), and I can even use formulas to make Z always end on a round
> number
> (i.e., I currently have it add between 10 and 19 to get to the next ##9).
>
> I want to be able to vary Z based on the level in the heading outline --
> e.g., top level headings will reserve up to the next multiple of 100, 4th
> level headings only reserve up to the next multiple of 10. But the only
> way
> to do that is to know what level in the heading outline the current text
> is
> at.
>
> Because many non-sophisticated people will be working in the document, I
> am
> reluctant to use anything that requires code.
>
> I think my workaround will be to add a "tag" to the document based on the
> style of the next pargraph using some temporary VBA, and then later I can
> run
> a find/replace to paste in the correct fields based on the type of "tag".
> I
> can either use some reusable code I have to find and replace with a field,
> or
> just put the fields in the clipboard and replace with ^c.
>
> So, thanks for the help. It seems strange that you can't access this
> info,
> since certain fields vary their behavior based on it (e.g., the \h switch
> in
> the SEQ field).
>
> "Jonathan West" wrote:
>
>>
>> "automandc" <automandc(a)discussions.microsoft.com> wrote in message
>> news:B3B0D733-0273-4BFF-A1AE-022DF9FBEECC(a)microsoft.com...
>> > That's helpful, but it doesn't answer the question. I want to place a
>> > field
>> > in bodytext and be able to calculate something based on the Outline
>> > Level
>> > of
>> > the immediately preceding heading. I.e., if the text appears under
>> > Heading
>> > 1, then x=1; if it appears under a Heading 3, then x=3.
>> >
>> > So. (1) can you get outline level from a field (I want to avoid VBA
>> > code
>> > in
>> > this document);
>>
>> No.
>>
>> > and (2) how do you find it for the immediately preceding
>> > heading when the field is in the body?
>>
>> You can't.
>>
>> Sorry the answer isn't more positive, but if it really can't be done, all
>> I
>> can say is "it can't be done"
>>
>>
>> --
>> Regards
>> Jonathan West - Word MVP
>> www.intelligentdocuments.co.uk
>> Please reply to the newsgroup
>>
>>
>>