locked
CreateObject("Excel.Application")' fails with message "Source unknown" RRS feed

  • Question

  • I have a PHP script running on an Apache server that will translate an Excel workbook to a PDF, and must create a COM object type Excel.Application to do so.

    It all works perfectly as long as I have have a RDP session running, but if there is no RDP session, the creation of the COM object fails with error message "Source unknown".

    I've configured the Apache service to allow interaction with desktop, and I've also tried having it log in using its own account with admin privileges.

    Also note that this was running perfectly for over 2 years on a different server, but we recently upgraded to new hardware and the problem began.

    Any help is greatly appreciated.

    Art

    Monday, February 15, 2016 7:54 PM

Answers

All replies

  • Hello Art,

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

    You may consider using the Open XML SDK instead, see Welcome to the Open XML SDK 2.5 for Office for more information. Or just any third-party components designed for the server side execution.

    Monday, February 15, 2016 8:40 PM
  • Advice is greatly appreciated, and we will work to re-engineer our solution, but in the interim is it possible to get an answer to our question.

    Why would the creation of a COM object of type Excel.Application fail when no desktop is running?

    Monday, February 15, 2016 8:51 PM
  • Hi adolimpio,

    >>Why would the creation of a COM object of type Excel.Application fail when no desktop is running?

    As the KB provided Eugene state:

    All current versions of Microsoft Office were designed, tested, and configured to run as end-user products on a client workstation. They assume an interactive desktop and user profile. They do not provide the level of reentrancy or security that is necessary to meet the needs of server-side components that are designed to run unattended.

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 16, 2016 2:20 AM
  • Yes, it's bad practice to do server side Excel stuff. It also can be configured to work. No clue if the following link will solve your problem but it works for us with the IBM Notes when used with Integra4Notes.

    http://www.integra4notes.com/faq/pages/0168

    Tuesday, February 16, 2016 5:32 PM
  • Perfect - thank you that did the trick.

    A solution rather than a lecture is greatly appreciated.

    Although I appreciate the potential issues associate with server-side Excel, I've tried numerous solutions, including OpenXML, to properly create a PDF in a manner that replicates the printed output from Excel, and they all had issues. Using VBScript and Excel is the only solution that I found that creates perfect output.

    Thanks again for your help!

    Art

    Tuesday, February 16, 2016 6:21 PM
  • Glad to assist. Some days you want elegant...other days you just want a sledge hammer.
    Tuesday, February 16, 2016 7:40 PM