locked
Excel save as pdf hangs when launched through a watch folder RRS feed

  • Question

  • 

    Hi there,

    I've configured a watch folder to launch a batch file which launch a .exe file I've written in C++

    In this application I launch Excel which open a .XLS document which contains macros.

    At the end of the computations there is a macro which save as pdf.

    At this point everything hangs and I have to cancel the job I've created for the watch folder.

    If I disable the watch folder and I place the starting file inside the watch folder

    and I manually launch the .bat file (which usually is launched by the watch folder) everything works perfectly.

    I really really hope there will be someone here coming with a solution for me.

    By the way on the windows forum I've got a very disappointing answer where they stated it was probably a fault of my application.

    Well fortunately that was not the problem because

    I can reproduce the problem even removing my application from the equation so now we have cleared

    the issue is not casued by my application.

    So if you want to try it yourself just follow the steps below:

    1) create an excel document so that after you open it it automatically run a save as pdf operation and close excel. (let's call this document "PRINT_TEST.xls")

    2) create a batch file named "Excel_launcher.bat" and write the command

    ""C:\Program Files\Microsoft Office 15\root\office15\EXCEL.EXE" "C:\teststampapdf\PRINT_TEST.xls""

    3) Now create a watch folder job that execute that batch file.

    something like "C:\watchfolderX\Excel_launcher.bat"

    4) now create a watch folder that uses that job and for file filter use "*.txt" enable it and start it

    5) now launch manually the batch file and you'll see that it print the pdf and closes itself

    6) drop a txt file inside the watch folder you've created and you'll see it hangs at the save as pdf operation.

    This is something that have to be fixed and it's due to excel.

    I can launch and save documents with all the application I want but excel so that's the problem.

    Please take a look and keep me updated I badly need to find a solution for this issue.

    THANK YOU in advance,


    Davide

    Friday, March 13, 2015 7:20 AM

All replies

  • Hi there,

    I've configured a watch folder to launch a batch file which launch a .exe file I've written in C++

    In this application I launch Excel which open a .XLS document which contains macros.

    At the end of the computations there is a macro which save as pdf.

    At this point everything hangs and I have to cancel the job I've created for the watch folder.

    If I disable the watch folder and I place the starting file inside the watch folder

    and I manually launch the .bat file (which usually is launched by the watch folder) everything works perfectly.

    I really really hope there will be someone here coming with a solution for me.

    I look forward to hearing from you.

    Have a nice day,


    Davide

    • Merged by L.Hl Tuesday, March 17, 2015 10:12 AM Merge Thread
    Friday, March 6, 2015 1:59 PM
  • Hi davide333,

    >> If I disable the watch folder and I place the starting file inside the watch folder and I manually launch the .bat file (which usually is launched by the watch folder) everything works perfectly.

    Based on my understanding, when you run .bat file manually, it ran under the current user​​. If you run it in file watcher, it ran under a specific system account (like system), it is similar with server side automation. The link below shows the details

    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.

    Considerations for server-side Automation of Office

    If you want to use the watch folder, I recommend you using the OpenXml SDK instead of COM automation. But the OpenXML SDK did not provide the function to convert the Excel spreadsheet to PDF.​

    Best Regards,

    Edward


    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.


    Monday, March 9, 2015 9:41 AM
  • Hi Edward,

    first of all thank you for your reply!!!

    The current user and the specific system account are the same in my case.

    So I can't see a real point for it to not work properly.

    So the point is instead of not recommending the AUTOMATION Microsoft should provide

    a valid solution for that. There are free applications which works fine in those automated

    condition so I would like to know why I should pay microsoft to have a limitaion of the automation

    possibilities?

    About the other solution switching to OpenXML SDK  that's not a solution for me

    because it doesn't support the print to pdf!

    Best,

    Davide

    Hi davide333,

    >> If I disable the watch folder and I place the starting file inside the watch folder and I manually launch the .bat file (which usually is launched by the watch folder) everything works perfectly.

    Based on my understanding, when you run .bat file manually, it ran under the current user​​. If you run it in file watcher, it ran under a specific system account (like system), it is similar with server side automation. The link below shows the details

    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.

    Considerations for server-side Automation of Office

    If you want to use the watch folder, I recommend you using the OpenXml SDK instead of COM automation. But the OpenXML SDK did not provide the function to convert the Excel spreadsheet to PDF.​

    Best Regards,

    Edward


    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.




    • Edited by davide333 Tuesday, March 17, 2015 11:03 AM
    Tuesday, March 17, 2015 11:02 AM
  • Just an ADVICE FOR THE USER THAT WILL READ this ANSWER. It's just an answer not a SOLUTION for my problem.

    Best,


    Davide

    Hi davide333,

    >> If I disable the watch folder and I place the starting file inside the watch folder and I manually launch the .bat file (which usually is launched by the watch folder) everything works perfectly.

    Based on my understanding, when you run .bat file manually, it ran under the current user​​. If you run it in file watcher, it ran under a specific system account (like system), it is similar with server side automation. The link below shows the details

    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.

    Considerations for server-side Automation of Office

    If you want to use the watch folder, I recommend you using the OpenXml SDK instead of COM automation. But the OpenXML SDK did not provide the function to convert the Excel spreadsheet to PDF.​

    Best Regards,

    Edward


    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, March 17, 2015 11:10 AM