Why I can't open ppt in windows service but in normal project it's ok? RRS feed

  • Question

  • I'm using Windows Service to convert ppt to video.

    The converting project works all fine if it's just an console project, but while I make it an windows service, here comes the Exception:

    System.Runtime.InteropServices.COMException (0x80004005): PowerPoint could not open the file.

    This happens when in the Open() method.

    Project Code:

    PowerPoint.Application pptApplication = new PowerPoint.Application();
    PowerPoint.Presentation ppt = pptApplication.Presentations.Open(fileName, 
    PowerPoint.PpSaveAsFileType format = PowerPoint.PpSaveAsFileType.ppSaveAsWMV;
    ppt.SaveAs(pathwmv, format, Microsoft.Office.Core.MsoTriState.msoFalse);


    I also cannot open the word files in code:

    Exception: System.Runtime.InteropServices.COMException (0x800A1098): 因为没有打开的文档,所以这一命令无效。


    Word.Application wordApplication = new Word.Application();
    Word.WdSaveFormat format = Word.WdSaveFormat.wdFormatPDF;
    wordApplication.ActiveDocument.SaveAs2(pathpdf, format);


    But when I convert pdf files it works all fine in the windows service.


    Can anyone tell me why this happens, the windows service's target plateform is set to be x86 in visual studio.

    --Thanks alice.yayun.ji

    Wednesday, October 17, 2012 8:43 AM

All replies

  • Hi Alice,

    Thank you for posting in the MSDN Forum.

    For the first snippet of code, please check whether this page can help you or not.

    I've tried the 2nd snippet of code in an console application, it works fine. Could you please provide all your code for further troubleshooting? You can upload it to SkyDrive and then share the link here. If your project is too large, you can create a short sample which can reproduce your scenario.

    I look forward to your reply.

    Best regards,

    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, October 18, 2012 11:18 AM