DevTun
DevTun

Reputation: 880

Open XML SDK : alternate content is ignored with word 2007

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 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 is empty.

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

Regards.


Yes you are right Taterhead , 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 textBoxContentForDrawing.Append(sdtBlockWithAltchunck) and textBoxContentForPicture.Append(sdtBlockWithAltchunck) , in this way I can get the the correct content in word2007 an 2010.

Regards

Reagards

Upvotes: 1

Views: 1913

Answers (2)

DevTun
DevTun

Reputation: 880

The problem is solved, the altchunk must be added before cloning the SdtBlock

Upvotes: 1

Taterhead
Taterhead

Reputation: 5951

Perhaps your //pict for word 2007 is not correct. Place it in the word for 2010 drawing block and see if it renders in 2010. Or place it outside of an alternate content block and make sure it renders in 2007.

Upvotes: 1

Related Questions