-1

Get "The specified package is invalid. The main part is missing" from WordProcessingDocument.Open()

I have two files: One is original file and another is Save As version from the original file.

Original get error at WordprocessingDocument.Open. Save As version is able to process normally.

I compared two files xml but nothing suspicious found.

The path and fileName is valid but it will hit error.

using (var wordDoc = WordprocessingDocument.Open(path + "/" + fileName, true))

“The specified package is invalid. The main part is missing.”

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Yin How
  • 89
  • 1
  • 7

1 Answers1

0

It is because the package you're trying to open is invalid. Please make sure the package has the part of "maindocument.xml".

This error may occur at this situation: the package tried to open is created by the windows context menu, then its size is 0 until you open the file and save it even without any changes in Word 2007. After open-and-save, the file should be opened correctly by the SDK

KeDaR
  • 71
  • 2
  • 14