Get and set a package stream in password-protected OOXML files

102 views Asked by At

Currently, we are using Sysyem.IO.Packaging namespace to get macros from various Office files.

Package package = Package.Open(stream, FileMode.Open, FileAccess.Read);
var pp = package.GetParts().FirstOrDefault(p => p.ContentType.Equals(@"application/vnd.ms-office.vbaProject"));
if (pp != null)
{
     ProcessMacros(pp.GetStream());
     ...

Similarly we save it back to the file in the end. However, this does not work for password-protected files. Is there a way to get/update the vbaProject stream programmatically by providing the valid password? Any 3rd party helper tools for that?

0

There are 0 answers