none
Alternate content ignored in word 2007 RRS feed

  • Question

  • Hi,

    I am generating word document using Open XML SDK, the document contain a textBox, the generated element for the textBox is in this form :

    <mc:AlternateContent>
          <mc:Choice Requires="wps">
             <w:drawing>
              // Drawing for word 2010
             </w:drawing> 
          </mc:Choice>
              <mc:Fallback>   
                <w:pict>
                 // Pict for word 2007
                </w:pict>   
              </mc:Fallback>
    </mc:AlternateContent>

    The generated document is valid when validated against 2007 and 2010 formats, when the document is opened with word 2010 the textBox is visible, but opening the document with word 2007 the textBox disappear.

    How can I add an alternate content that can be opened with both word 2010 and 2007.

    Regards.

    C'est sous cette forme
    Wednesday, March 14, 2012 5:06 PM

Answers

  • Hi Tunisian_BB,

    Do you mean that you want to add a control into a textbox? As far as I know, the textbox is an ActiveX control here. And I don't this you can copy the sdtBlock into its field. It will express as a EmbeddedControlPersistenceBinaryDataPart of the document. And it is a brinary stream of the document.

    I hope what I said can help you.

    Have a good day,

    Tom 


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Tunisian_BB Wednesday, March 21, 2012 10:49 AM
    Monday, March 19, 2012 6:35 AM
    Moderator

All replies

  • Hi Tunisian_BB,

    Thanks for posting in the MSDN Forum.

    Woudl you please show your code snippet to me. I don't think we can do further research on it via review only some part of your document.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, March 16, 2012 7:06 AM
    Moderator
  • Hi Tom_Xu,

    Thanx for your reply, what I am doing is adding a content control to the textbox, the content control contain an altchunk (to import content from external docx), after investigation i found that I'm adding the content control element (sdtBlock) to the textBox element in the drawing section (that is used in word2010) but I miss to add the content control to the picture section that is used in word 2007 and that is why i get an empty content control. So I need to add the content control (containing the altchunk) to the textBoxs in both drawing and picture, I try to clone the SdtBlock element, 

    textBoxContentForPict.Append(sdtBlock.CloneNode(true));

    the problem that the altchunk element is lost in the cloned sdtBlock. If you can help me to find a trick to add the SdtBlock to the 2 textBoxs in <w:drawing> textBoxContentForDrawing.Append(sdtBlockWithAltchunck)</w:drawing> and <w:pict> textBoxContentForPicture.Append(sdtBlockWithAltchunck)</w:pict> , in this way I can get the the correct content in word2007 an 2010.

    Reagards

    Friday, March 16, 2012 9:17 AM
  • Hi Tunisian_BB,

    Do you mean that you want to add a control into a textbox? As far as I know, the textbox is an ActiveX control here. And I don't this you can copy the sdtBlock into its field. It will express as a EmbeddedControlPersistenceBinaryDataPart of the document. And it is a brinary stream of the document.

    I hope what I said can help you.

    Have a good day,

    Tom 


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Tunisian_BB Wednesday, March 21, 2012 10:49 AM
    Monday, March 19, 2012 6:35 AM
    Moderator
  • Hi Tom, 

    The problem is solved, when cloning the SdtBlock the altchunk is not added yet to the SdtBlock, adding the altchunk before cloning the SdtBlock resolve the problem. Thank you for your assistance.

    Regards.

    Wednesday, March 21, 2012 10:49 AM