title: Invalid Procedure Call or Argument when passing Excel.Range from VBA to C# Library
body: <p>I have a C# Class Library project in Visual Studio that I am using to extend the functionality of a VBA project.</p>
  
  <p>I have made a COM accessible class that creates a TLB file on build; my VBA project references this TLB file.</p>
  
  <p>I want to be able to pass an Excel.Range object from VBA to my C# class; however I keep receiving the <strong>'Invalid Procedure Call or Argument'</strong> error and I don't understand why.</p>
  
  <p>C# Method:</p>
  
  <pre><code>public void SetMetrics(Excel.Range MetricRange)
  {
      //Implementation
  }
  </code></pre>
  
  <p>VBA Code:</p>
  
  <pre><code>ObjectName.SetMetrics (SheetName.Range("RangeName"))
  </code></pre>
  
  <p><strong><em>Test Outcomes:</em></strong></p>
  
  <ul>
  <li>If I create an alternative method with no parameters or alternative types such as int, bool etc - it works fine. The error only seems to occur when I try to pass a Range.</li>
  <li>If I make the VBA return a value form the method (see below), it works - <em>even though the method is explicitly defined with void.</em></li>
  </ul>
  
  <p>FunctionName = ClassName.SetMetrics (SheetName.Range("RangeName"))</p>
  
  <ul>
  <li>If I have more than one Excel.Range parameter - VBA forces me to return a value even if I do not want too; but this also works.</li>
  </ul>
  
  <p>I don't understand why I have these limitations - why do I have to return a value when passing objects to my library?</p>