title: Excel automation naming conflict "_FilterDatabase" - different behavior MFC ole automation vs. C# .NET
body: <p>Opening an Excel document by C++ MFC OLE automation shows a naming conflict ("_FilterDatabase") while the similar approach in C# .NET via Microsoft.Office.Interop.Excel does not.</p>
  
  <p>In my C++ MFC OLE Automation project I have imported the type library for excel.exe and selected the interfaces _Applicatin (CExcelApplication), _Workbook(CWorkbook) and Workbooks(CWorkbooks).</p>
  
  <p>In my C# .NET project I have added the COM reference "Microsoft Excel 16.0 Object Library".</p>
  
  <p>This is the code I'm using in the C++ MFC OLE automation project:</p>
  
  <pre><code>void OpenExcelDocument(const std::wstring&amp; strDocument)
  {
  
      // Create Excel object and bring Excel to the screen
      CExcelApplication appExcel;
      appExcel.CreateDispatch(L"Excel.Application");
  
      appExcel.put_Visible(TRUE);
  
  
      // obtain the Workbooks interface
      LPDISPATCH pDispWorkbooks = appExcel.get_Workbooks();
  
      if (pDispWorkbooks == NULL)
          return;
  
      CExcelWorkbooks workbooks;
      workbooks.AttachDispatch(pDispWorkbooks);
  
      // setup the default parameters
      VARIANT varDefault;
      memset(&amp;varDefault, 0, sizeof(varDefault));
      varDefault.vt = VT_ERROR;
      varDefault.scode = DISP_E_PARAMNOTFOUND;
  
      // open the document
      workbooks.Open(strDocument.c_str(),
          varDefault, varDefault, varDefault, varDefault, varDefault, varDefault, varDefault, varDefault,
          varDefault, varDefault, varDefault, varDefault, varDefault, varDefault);
  
  } 
  </code></pre>
  
  <p>The following code shows the similar approach via C# .NET</p>
  
  <pre><code>using Excel = Microsoft.Office.Interop.Excel;
  
  namespace ReadExcelDoc
  {
      class Program
      {
  
          static void OpenExcelDocument(String strDocument)
          {
              Excel.Application xlApp = new Excel.Application();
              xlApp.Visible = true;
  
              Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(strDocument);
          }
  
          static void Main(string[] args)
          {
              String xlsFile = @"..."; 
              OpenExcelDocument(xlsFile); 
          }
      }
  }
  </code></pre>
  
  <p>My questions are:</p>
  
  <ul>
  <li>Is this really internally the same approach for the Excel COM objects?</li>
  <li>Is there a way to avoid Excel prompting to resolve the naming conflict in my C++ MFC OLE automation approach despite altering the Excel document manually?</li>
  <li>Are my VARIANT default arguments in C++ specified correctly?</li>
  </ul>