title: How to populate Excel ComboBox with data from SQL Server?
body: <p>I am trying to populate a combobox in Excel file with data from SQL Server.</p>
  
  <p>Here is code for event:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Sub Workbook_Open()
  
  ActiveWorkbook.Sheets("Generation").Activate
  
  Set cn = New ADODB.Connection
  
  On Error Resume Next
  
  With cn
      .ConnectionString = "Provider=SQLOLEDB.1;" &amp; _
                          "Integrated Security=SSPI;" &amp; _
                          "Server=" &amp; "192.160.160.150;" &amp; _
                          "Database=" &amp; "em_Consumer;" &amp; _
                          "User Id= " &amp; "User" &amp; _
                          "Password = " &amp; "server123"
      .Open
  End With
  
  Set rs = New ADODB.Recordset
  
  sqltextexec = " SELECT name FROM sys.tables WHERE  schema_id = 7 AND name LIKE 'FinalCalculated%' ORDER BY create_date "
  
  rs.Open sqltextexec, cn
  
  rs.MoveFirst
  
  With Sheets("Generation").ComboBox1
      .Clear
      Do
          .AddItem rs![Name]
          rs.MoveNext
      Loop Until rs.EOF
  
  End With
  
  End Sub
  </code></pre>
  
  <p>This code works on my computer and on my colleague's as well (we are from DB team) but analysts who don't work with DB don't get list populated in the file.</p>
  
  <p>Is it possible the program uses Windows authentication to connect to the DB?</p>