none
Excel Office Automation: Not compiling in Windows Server 2012 R2 RRS feed

  • Question

  • I am using VS2015 VC++, SDK targetted for windows 10

    This is my code in header file, 

    #import "..\..\Components\ExcelController\MSExcel\mso.dll" rename_namespace("MSOFFICE") rename("RGB", "ofRGB") rename("DocumentProperties", "ofDocumentProperties")
    #import "..\..\Components\ExcelController\MSExcel\VBE6EXT.OLB" rename_namespace("MSVBEXT") rename("Application", "ApplicationVBExt") raw_interfaces_only 
    #import "..\..\Components\ExcelController\MSExcel\excel.exe" rename_namespace("MSEXCEL") rename("DialogBox", "DialogBoxEXC") rename("RGB", "RBGEXC") rename("DocumentProperties", "DocumentPropertiesEXC") rename("ExitWindows", "ExitWindowsEXC") named_guids

    When this is compiled on Windows Server 2012 R2, i get errors as below.

    error C4772: #import referenced a type from a missing type library; '__missing_type__' used as a placeholder
    d:\build\\debug\excel.tlh(2041): error C2516: '__missing_type__': is not a legal base class
      d:\program files (x86)\microsoft visual studio 14.0\vc\include\comdef.h(463): note: see declaration of '__missing_type__'
    d:\build\debug\excel.tlh(2041): error C2146: syntax error: missing ',' before identifier 'Adjustments'
    d:\build\debug\excel.tlh(2041): error C2499: 'MSEXCEL::Adjustments': a class cannot be its own base class
    d:\build\debug\excel.tlh(2083): error C2516: '__missing_type__': is not a legal base class
      d:\program files (x86)\microsoft visual studio 14.0\vc\include\comdef.h(463): note: see declaration of '__missing_type__'
    d:\build\debug\excel.tlh(2083): error C2146: syntax error: missing ',' before identifier 'CalloutFormat'
    d:\build\debug\excel.tlh(2083): error C2499: 'MSEXCEL::CalloutFormat': a class cannot be its own base class
    d:\build\debug\excel.tlh(2185): error C2516: '__missing_type__': is not a legal base class
      d:\program files (x86)\microsoft visual studio 14.0\vc\include\comdef.h(463): note: see declaration of '__missing_type__'
    d:\build\debug\excel.tlh(2185): error C2146: syntax error: missing ',' before identifier 'ColorFormat'
    d:\build\debug\excel.tlh(2185): error C2499: 'MSEXCEL::ColorFormat': a class cannot be its own base class
    d:\build\debug\excel.tlh(2246): error C2516: '__missing_type__': is not a legal base class
      d:\program files (x86)\microsoft visual studio 14.0\vc\include\comdef.h(463): note: see declaration of '__missing_type__'
    .....

    Any help to resolve this will be great.

    I can compile the code on Win 7 machine, the only difference is, it has MS Office installed.
    The Windows Server 2012 R2 machine does not have MS Office, does this matter?

    When the 2 excel.tlh files are compared they are different. I guess the excel.tlh file is not getting generated correctly.

    Need help in resolving the compiler errors please.

    Thanks,
    Saleem

    Wednesday, May 23, 2018 12:32 PM

Answers

  • Found the fix.

    Copying the 3 files to the location where the .cpp files reside in the project. Rebuild the project.

    The errors go away.

    Saleem

    Thursday, May 24, 2018 5:21 AM