Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i moved my code server 2012 i will get the following error.

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in PPTReadingConsoleApplication.exe


Retrieving the COM class factory for component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} failed due to the following error: 80040154


In my local system ms -office is there and working fine. but in server no ms office. how to read ppt data in server.

What I have tried:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;

namespace readPPT
{
class Program
{
static void Main(string[] args)
{
Microsoft.Office.Interop.PowerPoint.Application PowerPoint_App = new Microsoft.Office.Interop.PowerPoint.Application();
Microsoft.Office.Interop.PowerPoint.Presentations multi_presentations = PowerPoint_App.Presentations;
Microsoft.Office.Interop.PowerPoint.Presentation presentation = multi_presentations.Open(@"C:\ppt\RevisedKaizenTemplate.Rev1.pptx");
string presentation_text = "";
for (int i = 0; i < presentation.Slides.Count; i++)
{
foreach (var item in presentation.Slides[i + 1].Shapes)
{
var shape = (PowerPoint.Shape)item;
if (shape.HasTextFrame == MsoTriState.msoTrue)
{
if (shape.TextFrame.HasText == MsoTriState.msoTrue)
{
var textRange = shape.TextFrame.TextRange;
var text = textRange.Text;
presentation_text += text + " ";
}
}
}
}
PowerPoint_App.Quit();
Console.WriteLine(presentation_text);
Console.ReadLine();
}
}
}
Posted
Updated 30-Mar-17 4:18am
Comments
[no name] 30-Mar-17 9:47am    
"how to read ppt data in server", either install office on your server (probably not supported) or find a library that will read power point files without office installed.
RaultKlawas 2-Feb-18 6:02am    
As others have already mentioned, one way would be to use Office Interop, but that is not recommended on server because of various issues that may occur (for instance dead locks). Instead you could use this c# or vb.net library for powerpoints, it can enable you to read both PPT and PPTX files data.

You have to install PowerPoint on the server if you want to use Office interop.

Otherwise you need a library that is able to read PPT files.

If your files are OpenXML files (extension pttx), you can use the Open XML SDK 2.5 for Office[^].

The How to: Get all the text in all slides in a presentation (Open XML SDK)[^] seems to be what you want.
 
Share this answer
 
The problem with using any Office app via Interop is that it's not supported in a non-interactive logon session, i.e.: a web app or Windows service app.

If you're going to pull data out of any Office document, it's far better to use the OpenXml SDK and not interop.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900