From: automandc on 31 Jul 2007 22:12 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)
From: Russ on 1 Aug 2007 04:20 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
From: automandc on 1 Aug 2007 04:44 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 > >
From: Graham Mayor on 1 Aug 2007 05:17 There is no way you can determine from a field what the current paragraph style is - you can do it easily enough in vba eg Dim CurrStyle As Style Dim x As Integer Set CurrStyle = Selection.Style If InStrRev(CurrStyle, "Heading") Then x = Right(CurrStyle, 1) End If but without vba ...... -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> automandc wrote: > 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
From: Russ on 1 Aug 2007 05:49 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
|
Next
|
Last
Pages: 1 2 Prev: InlineShapes.AddPicture Next: programmatically move the anchor on a shape in a word document |