Share via

Word STYLEREF field parameters not co-operating - in particular \p

Anonymous
2013-01-11T01:14:46+00:00

I've been doing a little research into the STYLEREF field :

http://office.microsoft.com/en-us/word-help/field-codes-styleref-field-HP005186193.aspx

Trying to answer another question

http://answers.microsoft.com/en-us/office/forum/office_2007-word/word-2007-repeating-outline-heading-1-when-that/5015de6c-ad0c-4ec9-a94a-696c0c8fab30

I'm trying to get the \p parameter working and not having any luck.  If I can figure out how to use it I want to try using it in a condition to meet the needs of the original question.

The field by itself { styleref "heading 1" } works as advertised.

If I format the field { styleref "heading 1" \p "above" } In Word 2010 I get following error message:

"Error! Use the Home tab to apply  to the text that you want to appear hear". There are 2 spaces between the words "apply" and "to", as if there is an image missing

When I save to DOC format, and view the test doc in 2003 the message changes to "Error! Style not defined".  OK, that makes more sense. Except that the style is defined. In 2003 I changed the field to { styleref "heading 1" \p "Heading 1" }, but that didn't work either. Same style not defined message.

Here is an edit link to the sample file I've been playing with, feel free to make changes, fixes:

https://skydrive.live.com/redir?resid=E9A78C332557256F!307&authkey=!AAVBg4iMkEUeYS8

Bottom line, does anyone know the correct syntax to use the \p parameter?

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

7 answers

Sort by: Most helpful
  1. Stefan Blom 341K Reputation points MVP Volunteer Moderator
    2013-01-11T11:04:29+00:00

    And it still does not help because I need this parameter to work in the header.


    OK, that's the cause of trouble. The \p switch is ignored in headers and footers.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Doug Robbins - MVP - Office Apps and Services 323K Reputation points MVP Volunteer Moderator
    2013-01-11T04:43:03+00:00

    Hardly automatic, but in theory with a couple of nested If...then...Else fields to compare the output of the plain StyleRef field with a cross reference to the Text of the Heading and then one that compares the page number to cross reference of the Page Number of the Heading.  Problem is that the cross references are to the hidden bookmark assigned to the specific Heading so the field construction needs to be unique for each instance of Heading 1

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-01-11T04:03:21+00:00

    007

    In a new blank document add three paragraphs.

    In the first add:  { StyleRef "Heading 1" \p }

    In the second add: "Test" and format in Heading 1

    In the third add:  StyleRef "Heading 1" \p

    Toggle and update fields

    You should see:

    below

    Test

    above.

    All that palaver about "source bookmark" must be an error in the documentation.

    I don't think there is any way to automate a Heading 1 (Continued) process.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-01-11T03:19:39+00:00

    Thanks Suzanne, I was hoping you'd see this question.

    I finally got it to work, partially. Then again, I'm wrong. I must be misunderstanding how it is to be used.  

    It always shows "above" even when I select the whole doc and <f9> to update it. I've been adding and removing spaces to force the Heading 1 style on and off the same page.

    Any more suggestions for the original questioner?  I thought I could use the \P in an IF check to suppress the output on the "same page" to only display it if the body text spans a page as part of the "heading continued" type message he is looking to create.

    Was this answer helpful?

    0 comments No comments
  5. Suzanne S Barnhill 277.5K Reputation points MVP Volunteer Moderator
    2013-01-11T01:56:43+00:00

    You don't need anything after \p. Adding the \p switch causes the StyleRef field to display "above" if the referenced style occurs before the StyleRef field or "below" if it occurs after the field (see http://office.microsoft.com/en-us/word-help/field-codes-styleref-field-HP005186193.aspx). This switch actually makes more sense in the REF field, where those words may take the place of a page number, heading number, etc. If you want a reference such as "See Table 1 above," you'll actually need two StyleRef fields, just as you do when you want to reference both the paragraph number and the paragraph text.

    As a simple test, insert any text in a new blank document and format it as Heading 1. Press Enter to create a Normal paragraph below it. In that paragraph, insert a StyleRef field with the \p switch; when I insert it with the Insert | Field dialog in Word 2003, the result is { STYLEREF  "Heading 1" \p  \* MERGEFORMAT }, but of course the \* MERGEFORMAT switch is unnecessary, so { STYLEREF  "Heading 1" \p } will suffice. This should display as "above."

    Was this answer helpful?

    0 comments No comments