Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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");
		//Initialize 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.
Posted
Updated 27-Aug-19 1:22am
v2
Comments
Sampath579 1-Oct-19 0:45am    
Finally solved the issue on my self.

1 solution

Error codes are hexadecimal values, in this case 0x80080005. See hresult 80080005 - Google Search[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900