I have an ASP.NET 2.0 web application that needs to download a ppt file and then extract slides for images. To do this, I imported the assembly office.dll and Microsoft.Office.Interop.PowerPoint.dll and wrote the following code
public static int ExtractImages(string ppt, string targetPath, int width, int height)
{
var pptApplication = new ApplicationClass();
var pptPresentation = pptApplication.Presentations.Open(ppt, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
var slides = new List<string>();
for (var i = 1; i <= pptPresentation.Slides.Count; i++)
{
var target = string.Format(targetPath, i);
pptPresentation.Slides[i].Export(target, "jpg", width, height);
slides.Add(new FileInfo(target).Name);
}
pptPresentation.Close();
return slides.Count;
}
If I run this code on my local computer, in asp.net or an executable file, it works fine. But if I try to run it on a production server, I get the following error:
System.Runtime.InteropServices.COMException(0x80004005): PowerPoint . Microsoft.Office.Interop.PowerPoint.Presentations.Open(String FileName, MsoTriState ReadOnly, MsoTriState , MsoTriState WithWindow) PPTImageExtractor.PptConversor.ExtractImages(String caminhoPpt, String caminhoDestino, Int32 largura, Int32 altura, String caminhoThumbs, Int32 larguraThumb, Int32 alturaThumb, Boolean geraXml) Upload.ProcessRequest( HttpContext)
NT AUTHORITY\NETWORK SERVICE. IIS . , , .
- office 2010. 2007 . , Office 2003, .
, , -. - IIS7 .
, Open- API, , . DLLImport , , open-office -. , , .
.