Mandelbrotter
Mandelbrotter

Reputation: 2436

Opening up a PowerPoint file using Interop hangs on one users computer

I'm at a little loss on this one.

I have a C# application that creates PowerPoint presentations from a template file. This application works for all but one user.

On this users computer the application used to run fine but now hangs when trying to open up the PowerPoint file. The progress bar displays "Importing Template" so I know it's between ReportProgress("Importing Template"); and ReportProgress("Expanding Template");

using ppt = Microsoft.Office.Interop.PowerPoint;

private bool ExpandTemplateAndSave(string FileName)
{
   bool status = true;

   string path = Directory.GetCurrentDirectory() + "\\Resources\\pptTemplate.pptx";


   //Back up file is hard coded on server
   if (!File.Exists(path))
   {
      path = @"[Valid Server Path]\Test Build\pptTemplate.pptx";
   }

   ReportProgress("Importing Template");

   ppt.Application app = new ppt.Application();

   ppt.Presentation pres = app.Presentations.Open(path, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);

   ReportProgress("Expanding Template");
}

What could be causing this to hang?

Upvotes: 0

Views: 978

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49395

You need to pass a local file path to the Presentations.Open method which opens the specified presentation. Most Office applications can deal with a local file path only, so it seems PowerPoint can have the same limitation.

Another possible pitfall is network access. Firewalls and antivirus software may block applications from accessing remote endpoints.

Upvotes: 0

Related Questions