CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 19

Threaded View

  1. #1
    Join Date
    Jun 2021
    Posts
    51

    How to get instance Excel2016?

    Hi,
    My computer is installing 2 versions of excel10 and excel16.
    I use the following code to get the running excel instance but it only recognizes excel10.
    Code:
        LPWSTR pszExcelPath = 
    	  L"C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE";
    
        CreateProcess(pszExcelPath, NULL, 0, 0, 1,
    	  NORMAL_PRIORITY_CLASS, 0, NULL, &Start, &ProcInfo);
    I don't know what is the purpose of
    Code:
    for (int j = 1; j <= 5; j++)
    Although when I run the code, I always get pDisp!=nullptr but I can't query to workbooks from m_XLApp,...
    Code:
    m_XLApp.Attach(static_cast<Interface*> pDisp,true );
    if (pUnk)
    	pUnk->Release();
    wstring s{ m_XLApp->Caption }; <<--vs crash then out debugging.
    How I can fix this error?

    Edited: There aren't multiple instances running at the same time, I just want to get at least one running instance.

    Many thanks!
    Last edited by Dang.D.Khanh; July 6th, 2021 at 03:53 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured