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.
I don't know what is the purpose ofCode: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);Although when I run the code, I always get pDisp!=nullptr but I can't query to workbooks from m_XLApp,...Code:for (int j = 1; j <= 5; j++)
How I can fix this error?Code:m_XLApp.Attach(static_cast<Interface*> pDisp,true ); if (pUnk) pUnk->Release(); wstring s{ m_XLApp->Caption }; <<--vs crash then out debugging.
Edited: There aren't multiple instances running at the same time, I just want to get at least one running instance.
Many thanks!




Reply With Quote
