SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Error HRESULT E_FAIL has been returned from a call to a COM component.

    Hi everyone.

    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.

    Source Error:


    Line 52: objPresSet = objApp.Presentations;
    Line 53:
    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....

    Many thanks
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks for ur help.

    Suggestions?

    this is my code:

    Code:
        private void Page_Load(object sender, System.EventArgs e)
        {
            
                string PNG = @"D:\\Inetpub\\wwwroot\\public\\chart.png";
                string PPT = @"D:\\Inetpub\\wwwroot\\public\\temp.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;
                this.Chart1.SaveImage(PNG, ChartImageFormat.Png);
    
                Microsoft.Office.Interop.PowerPoint.Application
                objApp = new Microsoft.Office.Interop.PowerPoint.Application();
    
                Microsoft.Office.Interop.PowerPoint.Presentations
                objPresSet = objApp.Presentations;
    
                Microsoft.Office.Interop.PowerPoint._Presentation
                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);
    
                objPres.Close();
                objApp.Quit();                     
                      
    
                   
    
                      
        }
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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)....
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  6. #6
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    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.

  7. #7
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks... I think use the 'OpenXML', but I don't have idea... can you help me?
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •