Skip to content

Extract the ‘pdf’ file embedded in excel and save it in to a folder using c#

sandy jo

Asked Aug 21, 2011, 11:43 PM EDT1 answer
Share
LinkedInX

Hi All,

         I have an excel file with embed 'pdf' and 'doc' files.

I am able to read and save the 'doc' file.


C#
if (inlineShape.OLEFormat.progID.StartsWith("word.document."))
   {
       inlineShape.OLEFormat.Activate();
       Word.Document document = inlineShape.OLEFormat.Object as Word.Document;
       FileInfo wfi = new FileInfo(fileName);
       object wfileName = (object)(explodedDirectory + wfi.Name + "." + docCount.ToString() + ".doc");
       object fileFormat = Word.WdSaveFormat.wdFormatDocument;

document.SaveAs(ref wfileName, ref fileFormat, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing, ref _missing);

      document.Close(ref saveChanges, ref originalFormat, ref routeChanges);
      document = null;
   }

But can't do anything with pdf.

I need to extract the 'pdf' file and save it in to a folder.


Thanks in Advance

Sandy

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Suthish Nair
    0
    try inlineShape.OLEFormat.progID.StartsWith("AcroExch.document")
    0