Does CoGetInstanceFromFile work with worksheets?
What is wrong with the following code?
CoInitializeEx(NULL, COINIT_MULTITHREADED); int i(01);
for(; i < argc; i++) {
static MULTI_QI interfaces[01] = {&__uuidof(_Workbook), NULL, 00}; // i
tried also IID_IDispatch, does not work either
HRESULT code;
wcout << _T("Trying to open file ") << argv[i] << _T(" ... "); // argv[01]
== "sheet.xls"
if(SUCCEEDED(code = CoGetInstanceFromFile(NULL, NULL, NULL, CLSCTX_ALL,
STGM_READ, argv[i], 01, interfaces))) {
cout << _T("opened.") << endl;
interfaces-pItf-Release(); }
else {
wcout << _T("failed.") << endl;
HandleCOMError(code); } // code returned is E_NOINTERFACE
|