title: Pass a Range from VBA to C++
body: <p>I'm trying to send a Range from a VBA to a VSTO c++ DLL. The code below works fine if I'm using Excel 2010 64 bits but I get an error when I use it for excel 2016, any one knows how to solve it?</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include "ExcelImports.cpp"
  #include &lt;vector&gt;
  
  using namespace std;
  ofstream outputFile("outputFile.txt");
  
  double __stdcall RangeTest(Excel::RangePtr &amp;pRange, long N1, long N2 )
  {
  long sum = 0;
  
  for (int i = 1; i &lt;= N1; i++)
  {
      for (int j = 1; j &lt;= N2; j++)
      {
  
          outputFile &lt;&lt; (((Excel::RangePtr)pRange-&gt;Item[i][j])-&gt;Value).dblVal &lt;&lt; " ";
  
  
      }
  
      outputFile &lt;&lt; endl;
  
  }
   return 0;
  }
  </code></pre>
  
  <p>and the Other cpp file</p>
  
  <pre><code>#ifndef ExcelImports_cpp
  #define ExcelImports_cpp
  
  
  #import "C:\Program Files\Common Files\Microsoft Shared\OFFICE14\MSO.dll" rename ("DocumentProperties","DocumentsPropertiesXL") rename("RGB","RGBXL")
  #import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBE6EXT.OLB" 
  #import "C:\Program Files\Microsoft Office\Office14\EXCEL.EXE" rename ("DialogBox","DialogBoxXL") rename("RGB","RGBXL") rename ("DocumentProperties","DocumentsPropertiesXL") rename ("ReplaceText","ReplaceTextXL") rename ("CopyFile","CopyFileXL") no_dual_interfaces
  
  
  #endif
  </code></pre>
  
  <p>the defFile</p>
  
  <pre><code>Library "Teste"
  EXPORTS
  RangeTest
  </code></pre>