none
Problems manipulating content while using OpenSettings RRS feed

  • Question

  • Hello,

    i have a problem while manipulating content.

     

    (OpenSettings with MarkupCom. fileFormat.Office2007)

    Using wordDoc as WordProcessingDocument = WordProcessingDocument.Open(fileName,True,OpenSettings)

       
    Dim lXML as New XMLDocument
       lXML
    .Load(wordDoc.MainDocumentPart.GetStream(FileMode.Open, FileAccess.Read))

       
    ManipulateText(lXML)

       
    using streamWriter as New StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create))
          streamWriter
    .Write(lXML.InnerXML)
       
    end Using

    End using

    This code works fine but without to regard the OpenSetting FileFormat.Office2007. The created XMLDocument contains "AlternateContent" i.e.

    When using lXML.LoadXML(wordDoc.MainDocumentPart.Document.OuterXML) instead of lXML.Load(wordDoc.MainDocumentPart.GetStream(FileMode.Open, FileAccess.Read)) i only get the filtered content for Office2007.

    But when i try to write back this Xml nothing happens. Is it not possible to fill a XmlDocument by LoadXML and write it back to the DocumentPart by using a stream?

    Bjoern

    Wednesday, August 24, 2011 10:44 AM

Answers

  • Hi Bjoern,

    Do you want to change the the content in the document via OpenXml SDK? If so, please refer to this article:

    http://msdn.microsoft.com/en-us/library/bb508261.aspx

    which describes changing the text in the word document. And it uses the StreamReader and StreamWriter. I think it possible to fill the document via LoadXML and write it back to the document by using stream. In order to reproduce your problem, could you show me more code snippets?

    Hope this can help you and just feel free to follow up after you have tried.

    Best Regards,

     


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Bruce Song Monday, September 5, 2011 11:36 AM
    • Marked as answer by Bruce Song Wednesday, September 7, 2011 8:50 AM
    Monday, August 29, 2011 9:00 AM