Hi
I have a C++ project in which i am reading the excel sheet as follows: Note that i am using office 2016 version.
#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" \
rename("RGB", "ExcelRGB") \
rename("DocumentProperties", "MSODocumentProperties")
#import "libid:0002E157-0000-0000-C000-000000000046"
using namespace VBIDE;
#import "libid:00020813-0000-0000-C000-000000000046" \
rename("DialogBox", "ExcelDialogBox") rename("RGB", "ExcelRGB") rename("CopyFile", "ExcelCopyFile") rename("ReplaceText", "ExcelReplaceText") \
no_auto_exclude
HRESULT CReadExcel::OpenExcel(BSTR csInPath, BSTR csOutPath)
{
HRESULT hr = pApplication.CreateInstance(L"Excel.Application");
if ( hr != S_OK )
{
FILE* fp1 = nullptr;
fopen_s(&fp1, "D:\\Samples\\OpenBefore.txt", "w");
fprintf(fp1, "%d", hr);
fclose(fp1);
hr = E_FAIL;
goto wrapup;
}
}
In the above piece of code, CreateInstance is failing and returning -2146959355 error code. Not sure whats the meaning of this error code. Can any one explain why this function is failing and whats the meaning of error code and how to resolve this error?
Windows 1064bit
Office 365 64 bit
VS2017 Enterprise Edition.
-Sampath
What I have tried:
Tried many ways to avoid this error but unable to figure out the solution.