none
When i use c++ recreate a new powerpoint application as code is 「gcnew Microsoft::Office::Interop::PowerPoint::Application();」 ,i got the error that is System.Runtime.InteropServices.COMException (0x80080005) RRS feed

  • Question

  • if POWERPNT.EXE is already running on the machine when the application attempts to create a Power Point Application object that the Application contstructor throws an exception.the error is System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} failed due to the following error: 80080005.
    Monday, August 7, 2017 1:45 AM

All replies

  • Hi haku-itou,

    Thanks for visiting our forum.

    Then here we mainly focus on general questions about Office client. Since your query is about developing issues involving Office application, we'll move your thread to the following dedicated MSDN forum:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=officegeneral

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    • Marked as answer by haku-itou Tuesday, August 8, 2017 9:52 AM
    • Unmarked as answer by haku-itou Monday, August 21, 2017 7:31 AM
    Tuesday, August 8, 2017 5:13 AM
  • Hello,

    You can use the Marshal.GetActiveObject method which obtains a running instance of the specified object from the running object table (ROT). Take a look at the PowerPoint --> Marshal.GetActiveObject("PowerPoint.Application") forum thread for more information.

    Be aware, applications that are run under different integrity levels can't be automated. In that case you can show a message to a user asking to run your application as an administrator (or the opposite).


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, August 8, 2017 3:12 PM
  • Thanks for your answer.i have tried to use Marshal.GetActiveObject("Powerpoint.Application") for getting a running instance , i got another error.

    Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE)).

    Wednesday, August 9, 2017 2:22 AM
  • my code is

    while(Process::GetProcessesByName("POWERPNT")->Length != 1) Sleep(500);
    newApp = dynamic_cast<IAPP>(System::Runtime::InteropServices::Marshal::GetActiveObject("Powerpoint.Application"));
      if(newApp == nullptr){
              newApp  = proxy.NewApplication();
      }else{
         ***
      }

    Wednesday, August 9, 2017 4:13 AM
  • Hi haku-itou,

    According to your error message, I find a document which could explain the cause.

    Although the Office application is running, it might not be registered in the Running Object Table (ROT). A running instance of an Office application must be registered in the ROT before it can be attached to using GetObject (Visual Basic) or GetActiveObject (Visual C++).

    You could get more information and workaround from the document.

    https://support.microsoft.com/en-us/help/238610/getobject-or-getactiveobject-cannot-find-a-running-office-application

    Best Regards,

    Terry

    Wednesday, August 9, 2017 9:17 AM
  • Hi Terry,

    Thanks for your answer.According to that link document ,how can i register the running application to the Runnning Object Table(ROT).

    My code is

    HWND hwndCurrent = ::GetForegroundWindow();

    while(Process::GetProcessesByName("POWERPNT")->Length != 1) Sleep(500);
    //Restore the active window to the foreground...
    //  NOTE: If you comment out this line, the code will fail!
    ::SetForegroundWindow(hwndCurrent);

    //Initialize COM library...
    ::CoInitialize(NULL);

    //Attach to the running instance...
    CLSID clsid;
    CLSIDFromProgID(L"Powerpoint.Application", &clsid); 
    IUnknown *pUnk = NULL;
    IDispatch *pDisp = NULL;

    for(int i=1;i<=5;i++) //try attaching for up to 5 attempts
    {
     HRESULT hr = GetActiveObject(clsid, NULL, (IUnknown**)&pUnk);
       if(SUCCEEDED(hr))
       {
           hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDisp);
           break;
       }

      
       ::Sleep(1000);
    }

    if (!pDisp) {
        ::MessageBox(NULL, L"Failed to find instance!!", L"Error",
                     MB_ICONHAND);
    }
    else {
        ::MessageBox(NULL, L"Got instance of Excel!", L"Success", MB_OK);
    }

    i also can't failed to find that running Powerpoint Application.

    how can i check the running Powerpoint Application that has been registered in the Runnning Object Table(ROT)?

    Thursday, August 10, 2017 1:51 AM
  • Hi Terry

    Thanks for your answer. According to that link document ,i found that is「if your code is launching the Office application's exe file, you might need to wait for the Office application to finish loading before attempting to attach to the running instance.」.From that content when my code is trying to launch the Office application's exe file,i can use that solution.but now my proplem is that if POWERPNT.EXE is already running on the machine,i want to recreate a Powerpoint application that to open for another Powerpoint document.when do code gcnew Microsoft::Office::Interop::PowerPoint::Application() ,System.Runtime.InteropServices.COMException (0x80080005) error happens.

    For avoiding the error,not recreate a new powerpoint application. i tried to use System::Runtime::InteropServices::Marshal::GetActiveObject("Powerpoint.Application")) to get that has been running powerpoint application instance.but this also happens anther error that is Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE)).

    how can i solve the error?i can't get solution.

    my code is

    // start.
    HWND hwndCurrent = ::GetForegroundWindow();

    while(Process::GetProcessesByName("POWERPNT")->Length != 1) Sleep(500);
    //Restore the active window to the foreground...
    //  NOTE: If you comment out this line, the code will fail!
    ::SetForegroundWindow(hwndCurrent);

    //Initialize COM library...
    ::CoInitialize(NULL);

    //Attach to the running instance...
    CLSID clsid;
    CLSIDFromProgID(L"Powerpoint.Application", &clsid); 
    IUnknown *pUnk = NULL;
    IDispatch *pDisp = NULL;

    for(int i=1;i<=5;i++) //try attaching for up to 5 attempts
    {
     HRESULT hr = GetActiveObject(clsid, NULL, (IUnknown**)&pUnk);
       if(SUCCEEDED(hr))
       {
           hr = pUnk->QueryInterface(IID_IDispatch, (void **)&pDisp);
           break;
       }

      
       ::Sleep(1000);
    }

    if (!pDisp) {
        ::MessageBox(NULL, L"Failed to find instance!!", L"Error",
                     MB_ICONHAND);
    }
    else {
        ::MessageBox(NULL, L"Got instance of Powerpoint application!", L"Success", MB_OK);
    }

    // end.

    Thursday, August 10, 2017 5:39 AM
  • Hi haku-itou,
    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,
    Terry
    Friday, August 11, 2017 1:08 AM
  • Hi,Terry.

    Thanks for your help.Wait for some senior engineers's answer.Now i donnot have any idea to solve the problem.

    Best Regards,

    Haku

    Tuesday, August 15, 2017 9:59 AM
  • Hi

     

    Ø  The question falls into the paid support category which requires a more in-depth level of support. 

    Ø   

    Ø  Please visit the following link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Regards

    Saptarshi

    Thursday, August 31, 2017 3:12 PM