none
Missing space before cross reference code within Word XML RRS feed

  • Question

  • Hello,

    An operation that I performed seems to have eliminated all spaces from in front of cross references in all of my Word documents. I am now trying to figure out how to put the spaces back in. So, I have been trying to understand the Word XML, which is confusing.

    If you look in at the first screen shot below, you can see a missing space. In the red text, there is a ‘(see<’; I need to include a space after the ‘see’.

    You can also see the missing space just after the 'see' inside the open Word document in the second screenshot.

    If I use a tool to insert a space after the ‘see’, then open the Word document, sadly, the document looks just like it does in the second screen shot.

    So, I need to figure out how to insert the space. I wonder if the answer has something to do with the ‘<w:instrText xml:space="preserve">’ code. I experimented with that, without any joy.

    Any ideas appreciated!

    Many thanks.

    Keith


    R K Howard

    Wednesday, November 1, 2017 11:58 AM

Answers

  • Hello Keith,

    You are right. We should specify SpaceProcessingModeValues into Preserve.

      <w:r>
        <w:t>this is a test</w:t>
      </w:r>

    you could get "thisisatest"

    If you use:

      <w:r>
        <w:t xml:space="preserve">this is a test</w:t>
      </w:r>

    The string would be "this is a test".

    If you are using Open XML library to insert text, please use

                Text text1 = new Text(){ Space = SpaceProcessingModeValues.Preserve };
                text1.Text = "this is a test";

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 2, 2017 5:46 AM
    Moderator
  • You could resolve the matter with a simple Find/Replace, without going anywhere near the XML code. For example, press Alt-F9 to expose the field codes, then use:
    Find = ^d REF
    Replace = ^32^&
    after which you can press Alt-F9 again to hide the field codes.

    Slightly more complicated would be a macro that avoids the insertion of the space where there already is one.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, November 3, 2017 3:07 AM

All replies

  • Hello Keith,

    You are right. We should specify SpaceProcessingModeValues into Preserve.

      <w:r>
        <w:t>this is a test</w:t>
      </w:r>

    you could get "thisisatest"

    If you use:

      <w:r>
        <w:t xml:space="preserve">this is a test</w:t>
      </w:r>

    The string would be "this is a test".

    If you are using Open XML library to insert text, please use

                Text text1 = new Text(){ Space = SpaceProcessingModeValues.Preserve };
                text1.Text = "this is a test";

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 2, 2017 5:46 AM
    Moderator
  • Thank you Celeste! I suspect that that is a great tip. I need a few days to test this, and I will reply again here.

    Kind regards,

    Keith


    R K Howard

    Thursday, November 2, 2017 11:05 AM
  • You could resolve the matter with a simple Find/Replace, without going anywhere near the XML code. For example, press Alt-F9 to expose the field codes, then use:
    Find = ^d REF
    Replace = ^32^&
    after which you can press Alt-F9 again to hide the field codes.

    Slightly more complicated would be a macro that avoids the insertion of the space where there already is one.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, November 3, 2017 3:07 AM
  • Hi Celeste,

    Do you provide consultancy services? I could use a bit of hands-on help on this one. I'd like to show you some related stuff in a screen-sharing session.

    Many thanks.

    Keith


    R K Howard

    Friday, December 8, 2017 8:45 PM
  • Hello Keith,

    If you have any issues related to Word Object Model or Open XML SDK, please feel free to post on this forum https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=worddev or https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=oxmlsdk

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 11, 2017 1:53 AM
    Moderator