I have this problem: I developed a project website .net with visual studio 2010.
The website in local (my pc with windows XP) working properly, but If I export the same project website in other machine, server 2003, the same aspx page response with:
> Server Error in '/' Application.
Error HRESULT E_FAIL has been returned from a call to a COM component.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
Line 52: objPresSet = objApp.Presentations;
Line 54: Microsoft.Office.Interop.PowerPoint._Presentation
Line 55: objPres = objPresSet.Open(MyFilePPT, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
Line 56: Microsoft.Office.Interop.PowerPoint.Slide objSlides = default(Microsoft.Office.Interop.PowerPoint.Slide);
I see and applicate all solutions suggested for google search, but I don't resolve... please help me! I don't have more resources....
You really don't want to do this. Presuming you do have a licensed copy of PowerPoint on the server, you have to significantly elevate the privilige level so your web process can run Office. And then you still can't do anything when powerpoint throws up a modal dialog asking a user who isn't there to see the screen to click OK to continue.
thanks for ur help.
this is my code:
private void Page_Load(object sender, System.EventArgs e)
string PNG = @"D:\\\\Inetpub\\\\wwwroot\\\\public\\\\chart.png";
string PPT = @"D:\\\\Inetpub\\\\wwwroot\\\\public\\\ emp.ppt";
Chart1.Series["Default"].ChartType = SeriesChartType.Column;
Chart1.Series["Default"]["PointWidth"] = "0.3";
Chart1.Series["Default"].IsValueShownAsLabel = true;
Chart1.Series["Default"]["BarLabelStyle"] = "Center";
Chart1.Series["Default"]["PixelPointDepth"] = "20";
Chart1.Series["Default"]["DrawingStyle"] = "Cylinder";
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Inclination = 30;
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
objApp = new Microsoft.Office.Interop.PowerPoint.Application();
objPresSet = objApp.Presentations;
objPres = objPresSet.Open(PPT, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
Microsoft.Office.Interop.PowerPoint.Slide objSlides = default(Microsoft.Office.Interop.PowerPoint.Slide);
objApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
objSlides = objPres.Slides.Add(1, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutTitleOnly);
objSlides.Shapes.AddPicture(PNG, MsoTriState.msoCTrue, MsoTriState.msoCTrue, 0, 0);
objSlides.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 100, 100, 300, 300);
objSlides = objPres.Slides.Add(2, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutTitleOnly);
objSlides.Shapes.AddPicture(PNG, MsoTriState.msoCTrue, MsoTriState.msoCTrue, 100, 100);
objSlides.Comments.Add(1, 1, "v", "g", "c");
objSlides = objPres.Slides.Add(3, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutVerticalTitleAndText);
objSlides.Shapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect17, "The end", "Impact", 99, MsoTriState.msoFalse, MsoTriState.msoFalse, 200, 230);
objPres.SaveAs(FilePPTDaSalvare, PpSaveAsFileType.ppSaveAsPresentation, MsoTriState.msoTrue);
My suggestion is to try a different way -- this just won't work at all. Looking at what you are doing there is no reason at all to involve a web application, just make a macro or perhps an add-in for powerpoint.
thanks for your tips... I need save the "ChartImageFormat.Png" generate with "chart control" and add this image in the slide of model power point "temp.ppt"... but i'm newbie for .NET and I need examples or macro or add-in for powerpoint... can you help me? Any link?
Please... because I don't understand why the same application works in development (Windows XP) and not work in a practice (Windows Server 2003)....
The problem isn't the platform but rather where it is executing the code. Your ASP.NET server-side code is executed on the server. When you are developing that probably is also your machine so it can access PowerPoint and open the window for you. When you move it to the server, it doesn't have PowerPoint installed and can't open it on your local machine anyway. There is some security issues on top of this -- mainly the web process on the server probably could not fire off powerpoint successfully even if it had it available.
See MSDN for examples and samples of doing office add-in development. I know there are windows forms versions of the chart controls, so that should probably let you generate it offline. The same code you are using to insert the chart should work there as well.
thanks... I think use the 'OpenXML', but I don't have idea... can you help me?
This topic is now archived. It is frozen and cannot be changed in any way.