none
system.io.pacakging class RRS feed

  • Question

  •  

    hello everyone,

     

                           I have installed the openxmlsdk and added reference to my word add-in project but i couldnt get the package class in my project. i need to implement this

     

     

    using (Package package = Package.Open("mydocument.docx"))

    {

       

       }

     

     

    string relID= rId1;

    PackageRelationship imagerelationship = mainPart.GetRelationship(relID);

     

    in my project

     

    namespace wordplugin

    {

    public partial class ThisAddIn

    {

    const string wordmlNamespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";

    const string relationshipNamespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";

    private void ThisAddIn_Startup(object sender, System.EventArgs e)

    {

    this.Application.DocumentOpen += new Microsoft.Office.Interop.Word.ApplicationEvents4_DocumentOpenEventHandler(Application_DocumentOpen);

    }

    void Application_DocumentOpen(Microsoft.Office.Interop.Word.Document Doc)

    {

           // implement the package class to retrieve the a .xml file using the relationship id "context" and retreive the

          cx : docid and cx : scope in a message box here. so that the a file is opened using the word it checks for the context.xml file with the realtionship id and display the content in message box.

    }

     

    my relationship id is

     

    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>

    - <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
       <Relationship Id="context" Target="docProps/context.xml" Type="http://www.fit.fraunhofer.de/xml/context1.0" />
      </Relationships>
     
    my .xml file content is
     
    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    - <cx:context xmlns:cx="http://www.fit.fhg.de/context/spec1.1/" cx: docid="860a4b2e-81c0-4320-970a-f927bc053c0b">
      <cx: scope cx:initdata="1192198631222" cx:lastvisit="1192198631222" cx:url="http://saafi.fit.fhg.de/contextbroker/" />
      </cx:context>
     
     
    or is there any other way to do this.
    Thank you.
    Thursday, March 20, 2008 12:17 PM