Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3029

How to get instance Excel2016?

$
0
0
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?

Many thanks!

Viewing all articles
Browse latest Browse all 3029

Latest Images

Trending Articles



Latest Images