none
How to use the word 2007, so that <w:sdtRun> change to <w:sdtBlock> RRS feed

  • Question

  • In the office word 2007, we use such as a programmable through <w:sdtContent> produce documents, but in the office word 2007 file operations, there may have two kinds of <w:sdtElement>, that is, <w: sdtBlock "and <w:sdtRrun>, because it corresponds to the different stylized <w:sdtElement> is different.

    Such as: <w:sdtBlock> that contains a paragraph, but <w:sdtRun> is that it contains a paragraph. This will allow the program design methods are different.

    When I want a single paragraph <w:sdtElement> use <w:sdtBlock>, but not through the office word 2007 be <w:sdtRun> changed to <w:sdtBlock>.

    I do not know what to do?

    Monday, January 18, 2010 11:34 AM

Answers

  • Hi 雷克斯蕭,

    Thanks for your description.

    There are many kinds of content controls in Word, you could refer to this link: http://blogs.msdn.com/microsoft_office_word/archive/2006/11/17/meet-the-controls.aspx

    Specifically in your case, many operations are done automatically by Word and it's not so easy to use Word UI to get the xml format exactly you want. I have tried some test files and I think you could try to use "Rich Text Content Control" instead of "Plain Text Content Control" to achieve this.

    In your Ex2, two content controls are in the same paragraph, in which even "Rich Text Content Control" can only contain one line. Once you delete one of them, you could try to add new paragraphs to the remaining one, then Word will automatically change <p>/<sdt> to <sdt>/<p>.

    On the contrary, if you want to change <sdt>/<p> to <p>/<sdt>, you could try to add some text before or after the content control.

    As to the type of sdtElement, you could call SdtElement.GetType() in OpenXml SDK to know what type it is.

    Hope this will help you. If you have any questions, please let me know.

    Thanks,

    Lu
    • Marked as answer by 雷克斯蕭 Wednesday, January 27, 2010 4:32 AM
    Monday, January 25, 2010 7:32 AM

All replies

  • Some people look at my question got it?

    help~
    Tuesday, January 19, 2010 4:10 PM
  • Hi 雷克斯蕭,

    Thanks for your quesion.

    I don't quite understand the following, could you describe it in detail about your scenario or application? 

    When I want a single paragraph <w:sdtElement> use <w:sdtBlock>, but not through the office word 2007 be <w:sdtRun> changed to <w:sdtBlock>

    In addition, as far as I know, the tag names of SdtBlock and SdtRun are both <w:sdt>. Although they inherit the same base class SdtElement, they are defined differently. <w:sdt> for SdtBlock is Block-Level Structured Document Tag, while <w:sdt> for SdtRun is Inline-Level Structured Document Tag. You could use Open XML SDK 2.0 Productivity Tool to get these file format information in detail. So if you want to replace one with the other, it is somehow complicated.

    If you have any questions, please let me know.

    Thanks,

    Lu
    Wednesday, January 20, 2010 9:47 AM
  • hello ,many thanks for your response,my description is as follows

    Ex 1: single paragraph,single x:sdt,it is sdtElement,and xml output x:sdtBlock

    按一下這裡以輸入文字。

     

    Ex 2:single paragraph,multi x:sdt,it is sdtElement, and xml output x:sdtRun

    按一下這裡以輸入文字。按一下這裡以輸入文字。

     

    Ex3:when firs time like Ex 2,and delete last x:sdtElement,the xml output x:sdtRun

    按一下這裡以輸入文字。

     

    My question is how to use Word2007 Application UI,let ex3 result the same with ex1 result

     

    Ex1: XML

    <w:sdt xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">

      <w:sdtPr>

        <w:id w:val="369428141" />

        <w:placeholder>

          <w:docPart w:val="7DAEA7789475410683434A988EFB5F36" />

        </w:placeholder>

        <w:showingPlcHdr />

      </w:sdtPr>

      <w:sdtContent>

        <w:p w:rsidR="00D45BB8" w:rsidRDefault="00B3566C">

          <w:r w:rsidRPr="006829B5">

            <w:rPr>

              <w:rStyle w:val="a3" />

              <w:rFonts w:hint="eastAsia" />

            </w:rPr>

            <w:t>按一下這裡以輸入文字。</w:t>

          </w:r>

        </w:p>

      </w:sdtContent>

    </w:sdt>

     

    Ex2:XML

    <w:p w:rsidR="00B3566C" w:rsidRDefault="00760026" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">

      <w:sdt>

        <w:sdtPr>

          <w:id w:val="369428142" />

          <w:placeholder>

            <w:docPart w:val="E6D5A5BB94404A6382FDCF976E3C3411" />

          </w:placeholder>

          <w:showingPlcHdr />

        </w:sdtPr>

        <w:sdtContent>

          <w:r w:rsidRPr="006829B5" w:rsidR="00B3566C">

            <w:rPr>

              <w:rStyle w:val="a3" />

              <w:rFonts w:hint="eastAsia" />

            </w:rPr>

            <w:t>按一下這裡以輸入文字。</w:t>

          </w:r>

        </w:sdtContent>

      </w:sdt>

      <w:sdt>

        <w:sdtPr>

          <w:id w:val="369428159" />

          <w:placeholder>

            <w:docPart w:val="AFA465D51D6B48F6AA83A8F4264E5CC6" />

          </w:placeholder>

          <w:showingPlcHdr />

          <w:text />

        </w:sdtPr>

        <w:sdtContent>

          <w:r w:rsidRPr="006829B5" w:rsidR="00B3566C">

            <w:rPr>

              <w:rStyle w:val="a3" />

              <w:rFonts w:hint="eastAsia" />

            </w:rPr>

            <w:t>按一下這裡以輸入文字。</w:t>

          </w:r>

        </w:sdtContent>

      </w:sdt>

    </w:p>

     

    Ex3:XML

    <w:p w:rsidR="00B3566C" w:rsidRDefault="00760026" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">

      <w:pPr>

        <w:rPr>

          <w:rFonts w:hint="eastAsia" />

        </w:rPr>

      </w:pPr>

      <w:sdt>

        <w:sdtPr>

          <w:id w:val="369428161" />

          <w:placeholder>

            <w:docPart w:val="D6E7C3AA464E4C1E8334951701DED991" />

          </w:placeholder>

          <w:showingPlcHdr />

        </w:sdtPr>

        <w:sdtContent>

          <w:r w:rsidRPr="006829B5" w:rsidR="00B3566C">

            <w:rPr>

              <w:rStyle w:val="a3" />

              <w:rFonts w:hint="eastAsia" />

            </w:rPr>

            <w:t>按一下這裡以輸入文字。</w:t>

          </w:r>

        </w:sdtContent>

      </w:sdt>

    </w:p>

     

    Friday, January 22, 2010 1:55 AM
  • I've been using Open XML SDK 2.0 Productivity Tool, my question is, when the user creates <x:sdtEelment>, I will go through the SDK tools, but I can not expect <x:sdtElement> what kind, and the user is also Do not know, because in word 2007, the look is the same look.
    Friday, January 22, 2010 2:38 AM
  • Hi 雷克斯蕭,

    Thanks for your description.

    There are many kinds of content controls in Word, you could refer to this link: http://blogs.msdn.com/microsoft_office_word/archive/2006/11/17/meet-the-controls.aspx

    Specifically in your case, many operations are done automatically by Word and it's not so easy to use Word UI to get the xml format exactly you want. I have tried some test files and I think you could try to use "Rich Text Content Control" instead of "Plain Text Content Control" to achieve this.

    In your Ex2, two content controls are in the same paragraph, in which even "Rich Text Content Control" can only contain one line. Once you delete one of them, you could try to add new paragraphs to the remaining one, then Word will automatically change <p>/<sdt> to <sdt>/<p>.

    On the contrary, if you want to change <sdt>/<p> to <p>/<sdt>, you could try to add some text before or after the content control.

    As to the type of sdtElement, you could call SdtElement.GetType() in OpenXml SDK to know what type it is.

    Hope this will help you. If you have any questions, please let me know.

    Thanks,

    Lu
    • Marked as answer by 雷克斯蕭 Wednesday, January 27, 2010 4:32 AM
    Monday, January 25, 2010 7:32 AM
  • Thank you for your reply

    I think this is the right answer, but most of the situation we face are not programmers, and in some complex cases, the design staff of Word documents may not be able, as we expected.

    Of course, this is as a programmer should be to challenge problems.

    Once again, thank you very carefully and enthusiastic reply.
    Wednesday, January 27, 2010 4:37 AM