Quantcast
Channel: Open XML Format SDK forum
Viewing all articles
Browse latest Browse all 1288

Open XML avd Word 2007

$
0
0
Hi all!

 I programmatically insert the first document (temlate.xml) into  the second document (dummy.docx) and use the following code taken from official Microsoft site (http://msdn.microsoft.com/en-us/library/office/bb456489.aspx):

    Protected Sub btn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn.Click
        Dim fromDocument1 As String ="templates\template.xml"
        Dim toDocument2 As String = "templates\dummy.docx"
     
        AddNewPart(toDocument2, fromDocument1)

    End Sub

    Public Sub AddNewPart(ByVal document As String, ByVal fileName As String)
        Using wordDoc As WordprocessingDocument = WordprocessingDocument.Open(document, True)
            Dim mainPart As MainDocumentPart = wordDoc.MainDocumentPart

            Dim myXmlPart As CustomXmlPart = mainPart.AddCustomXmlPart(CustomXmlPartType.CustomXml)

            Using stream As New FileStream(fileName, FileMode.Open)
                myXmlPart.FeedData(stream)
            End Using
        End Using
    End Sub

But I see nothing in combined document (dummy.docx) althogh when I open this file as archive I see there the part (compressed folder) "customXML". There is the file "item.xml" in this folder, which I can open and  see there the content of my template (Template.xml). That is this content is present in the combined file but I don't see it. What I do wrong?


Viewing all articles
Browse latest Browse all 1288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>