none
The specified package is invalid. The main part is missing RRS feed

  • Question

  • Hi There,

    I have created a new docx document and want to open it using the OpenXML SDK.

    Here is my code:

    Package package = Package.Open(document);
    
    WordprocessingDocument doc = WordprocessingDocument.Open(package);

    When the code is executed I get the following error:

    The specified package is invalid. The main part is missing

    Can someone help please!


    Ek hoor stemme

    Friday, June 29, 2012 7:30 AM

Answers

  • Hi Marius,

    It's based on my experience that we will us following snippet to open WordprocessingDocument :

    using (var document = WordprocessingDocument.Open(fileName, true))
    {
        var doc = document.MainDocumentPart.Document;
        // Code removed here…
    }
    

    Would you please try it?

    Best Regards,

    T.X.


    征诛志异,三让两家王朝
    功同开辟,一桮万古江南

    Saturday, June 30, 2012 2:39 AM

All replies

  • Hi Marius,

    It's based on my experience that we will us following snippet to open WordprocessingDocument :

    using (var document = WordprocessingDocument.Open(fileName, true))
    {
        var doc = document.MainDocumentPart.Document;
        // Code removed here…
    }
    

    Would you please try it?

    Best Regards,

    T.X.


    征诛志异,三让两家王朝
    功同开辟,一桮万古江南

    Saturday, June 30, 2012 2:39 AM
  •  WordprocessingDocument.Open(package)

    "package" should be right filename and path name!!

    like "templates\\mytemp.docx" !!

    I just got this error msg, and only modify <filename> is OK!!

    Thursday, September 5, 2013 8:46 AM