Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    May 2007
    Location
    Idaho Falls, Idaho, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nonbreaking Space in Fields (Word2003 SP2)

    I have some cross-references to tables and figures. I want the fields to use non-breaking spaces (i.e., 'Table 1-1' should not break between the 'Table' and the '1-1').

    I use the following macro to replace the spaces with nonbreaking spaces.
    <pre>For Each rngStory In doc.StoryRanges
    For Each fldField In rngStory.Fields
    If fldField.Type = wdFieldRef Then
    fldField.Select
    With Selection.Find
    .ClearFormatting
    .Text = " "
    .Replacement.ClearFormatting
    .Replacement.Text = Chr(160)
    .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindStop
    End With
    End If
    Next fldField
    Next rngStory
    </pre>


    It works great when in 'Normal View.' But when I switch to 'Print View,' all the nonbreaking spaces get changed to regular spaces. When I switch back to 'Normal View,' the normal spaces are still there.

    Why do I lose the nonbreaking spaces when switching to 'Print View'? Is there anything to be done?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Nonbreaking Space in Fields (Word2003 SP2)

    Welcome to Woody's Lounge!

    The content of cross reference fields is set by Word, it is not freely editable.
    When you switch from Normal view to Page Layout view, the cross reference fields get updated, i.e. their content is regenerated by Word.
    You'd have to replace the space between Table and 1-1 in the caption of the table with a non-breaking space. The cross-reference would then automatically use a non-breaking space too, even after being updated.

  3. #3
    New Lounger
    Join Date
    May 2007
    Location
    Idaho Falls, Idaho, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Nonbreaking Space in Fields (Word2003 SP2)

    Excellent, Hans. I'll try this tomorrow morning.

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Nonbreaking Space in Fields (Word2003 SP2)

    As Hans says, if you only put the non-breaking spaces in the cross-ref fields then whenever the fields are updated the content of the target comes back into the cross reference. Sooo - you need to put the non-breaking space into the caption itself and then update the fields.

    I do this with a search and replace for "Figure " with "Figure " where the second one uses a non-breaking space. I then do the same thing with "Table ".

    You lose the spaces when you go to Print View because your options are set to update the fields on printing. Check under Tools>Options>Print
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •