Search code examples
visual-c++comexcel-2010atl

ATL errors compiling 64-bit COM excel addin


I have a C++ ATL COM adding that implements some utility functions that refer to the Excel API:

void DoSomething(CComPtr<Excel::Range> &masterCell)
{
    // ...
    CComPtr<Excel::Range> cell = masterCell->Offset[vertical][horizontal];
    // ...
}

When compiling an excel addin for x64 I'm getting lots of spurious errors such as:

cannot convert from 'Excel::Range' to 'ATL::CComPtr<T>'

However, when I compile for Win32 there is no problem. The helper utility functions are not exposed as excel UDF's so I don't think this question is applicable since the function does not have a STDMETHODIMP part.

Any ideas?

Thanks in advance.


Solution

  • Doh! Turns out that I was trying to reference a 32-bit excel installation in a 64-bit build:

    https://social.msdn.microsoft.com/Forums/en-US/f069ea06-b888-47c0-9ec8-c6cf8a59d9b1/atl-errors-compiling-64bit-com-excel-addin?forum=exceldev

    Installing 64-bit excel fixed the issue.