0

I want to import excel driver in c++ using ExcelImport.cpp file but the visual studio is unable to open my file. I am giving the directory of my c folder but the visual studio is looking in its directory folder. I already include my path in additional directories but it's not working I want to write results in an excel file. Here are my include paths and the error list.

I want to do the same exactly that is followed by under this link but in my case the imports are not working

interface with excel c++

ExcelImports.cpp

#import "C:\Program Files\Microsoft Office 15\root\VFS\ProgramFilesCommonX86\Microsoft Shared\OFFICE15\MSO.DLL"
#import "C:\Program Files\Microsoft Office 15\root\VFS\ProgramFilesCommonX86\Microsoft Shared\VBA\VBA6\vbe6ext.olb"
#import "C:\Program Files\Microsoft Office 15\root\Office15\excel.exe"

MyfunctionCode.cpp

double GetDoubleFromCell(Excel::_WorksheetPtr sheet, CComBSTR cell)
{ 

    Excel::RangePtr range=sheet->GetRange(CComVariant(cell));
    _variant_t value=range->GetValue2();
    return value;
}

I am trying to import MSO.dll file but it is importing MSO.tlh

output Window :

Build started...
1>------ Build started: Project: ExcelVisualisation, Configuration: Debug Win32 ------
1>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
1>E:\Hamza ku\Tuition C++\Level9\Level9Code\Level9Code\Projects\ExcelVisualisation\Debug\ExcelVisualisation.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "ExcelVisualisation.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Hamza Asif
  • 76
  • 8
  • Those are intellisense errors. Please copy/paste the *compiler* errors from the Output window (not the Error List window). `C:\Program Files\Microsoft Office 15\root\VFS\ProgramFilesCommonX86\Microsoft Shared` Does that path actually exist on your machine? `it is importing MSO.tlh` The `.tlh` file gets created by the `#import` directive, unless of course the `#import` failed. – dxiv Dec 29 '20 at 01:22
  • these are the errors after compilation. And yes C:\Program Files\Microsoft Office 15\root\VFS\ProgramFilesCommonX86\Microsoft Shared this path exists in my machine .tlh files is automatically generated and ofcoure there are errors for importing – Hamza Asif Dec 29 '20 at 07:54
  • Please copy/paste the compiler errors from the Output window (not the Error List window). – dxiv Dec 29 '20 at 08:18
  • 1>E:\Hamza ku\Tuition C++\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp(1,9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>E:\Hamza ku\Tuition C++\ConsoleApplication1\ConsoleApplication1\Debug\mso.tlh(13,18): error C2143: syntax error: missing ';' before '{' 1>E:\Hamza ku\Tuition C++\ConsoleApplication1\ConsoleApplication1\Debug\mso.tlh(13,18): error C2447: '{': missing function header (old-style formal list?) – Hamza Asif Dec 29 '20 at 08:39
  • Please [edit](https://stackoverflow.com/posts/65483346/edit) the relevant information into the question, not comments. Including the related code in `ConsoleApplication1.cpp` and at least the first 20 lines or so of `mso.tlh`. Also, which versions of `mso.dll` and `vbe6ext.olb` are you referencing, and do they come from an installation proper of Office15? – dxiv Dec 29 '20 at 08:51
  • yes, MSO.dll and vbe6ext.olb is coming from office installation you can find in your system as well. please check the question as well I am updating – Hamza Asif Dec 29 '20 at 12:17
  • That doesn't show any compiler errors, just the linker error [LNK2019: unresolved external symbol _main](https://stackoverflow.com/questions/33400777/error-lnk2019-unresolved-external-symbol-main-referenced-in-function-int-cde). Do a Rebuild All and copy any compiler errors that occur before LNK2019, and any `.cpp` code related to those errors. – dxiv Dec 29 '20 at 16:46

0 Answers0