Running multiple PowerPoint automation processes in parallel RRS feed

  • Question

  • Hi,

    I am trying to automate PowerPoint file creation using my VB.NET program which uses PowerPoint's COM API to add/delete, copy/paste shapes on PowerPoint slides. The problem I am facing is that I am not able to run multiple instances of my process in parallel such that they create 2 pptx files in parallel. 
    After some search I found that POWERPNT.exe is a single COM server process and thus all COM calls eventually gets serialized.
    I was wondering if there is any way to wrokaround this limitation and run multiple VB.NET automation processes in parallel. I Know that one way is to ditch COM automation and use 'Open XML SDK', but that would mean re-writing the whole application.



    Monday, June 17, 2013 10:19 AM

All replies

  • Hi Rahul,

    Thank you for posting in the MSDN Forum.

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards,

    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, June 18, 2013 1:15 PM
  • Hi Rahul,

    For your scenario, I do agree that switching to Open XML sdk would be a reasonable way to thorougly resolve the problem. If you still want to use the COM automation API, you can consider create a deciated application (such as a console) which encapsulate the pptx file generation code (using COM automation API) and then use Process class to invoke that separate application (multiple times) in your VB.NET application. In that way, each console process should have their own STA COM context. But you will need to other ways (like inter-process communication or use database/log files) to determine if the pptx files is generated or not.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, June 19, 2013 12:57 PM
  • Hi Steven,

    Your solution seems fine, but won't all the COM calls get serialized in PowerPoint? Since PowerPoint is just a single process serving multiple clients (the console application). If that's the case then the purpose of parallel processing is not met, because eventually everything is serialized at PowerPoint level.

    The above statements are based on the following paragraph which I found somewhere on the internet. Please let me know if its not correct and PowerPoint can actually serve multiple console applications running in parallel (The console applications will also be doing shape.Select, slide.Copy etc.).

    "COM creates a hidden window using the Windows class "OleMainThreadWndClass" in each single-threaded apartment (STA thread model). A call to an object is received as a window message to this hidden window. When the object's apartment retrieves and dispatches the message, the hidden window will receive it. The window procedure will then call the corresponding interface method of the object.
    When multiple clients call an object, the calls are queued in the message queue and the object will receive a call each time its apartment retrieves and dispatches messages. So the calls are synchronized by COM and the calls are always delivered by the thread that belongs to the object's apartment"



    Wednesday, June 19, 2013 4:38 PM