title: Refresh QueryTable throwing "General ODBC error" - VBA Excel 2011 for Mac
body: <p><strong><em>EDIT: New mistake found?</em></strong></p>
  
  <p>I may have just found out why my script wouldn't work anymore. There has been an office update recently and it seems they have implemented the microsoft query which gets rid of the ODBC-Manager which I installed and configured to my needs. Now the actual problem may be that this microsoft query doesn't have the UNICODE-library and I don't know where I could put them so that the microsoft query would read/get them. Or rather I don't know how to give the microsoft query the path to the UNICODE-library as in the manager there is no possibility to change it, or maybe there is and I just didn't find it? In addition to this I cannot open the microsoft query manager unless I open it directly from the excel workbook. </p>
  
  <p><strong><em>ORIGINAL QUESTION</em></strong> </p>
  
  <p>This code worked for some time. Now with the exact same code I get a runtime error. <a href="https://stackoverflow.com/questions/33998229/vba-mac-connect-to-sql-server-with-actualtech-odbc-driver">Here</a> I already asked for help in this case and got it to work.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>Sub ConnectSQL()
  
      Dim connstring As String
      Dim sLogin As String
      Dim qt As QueryTable
  
      sLogin = "Uid=*;Pwd=*;"
      sqlstringFirma = "select * from gi_kunden.tbl_Firma"
      sqlstringPerson = "select * from gi_kunden.tbl_Person"
      connstring = "ODBC;DSN=KundeDB;" &amp; sLogin
  
      ActiveWorkbook.Sheets("Firma").Select
      ActiveSheet.Range("A1:T2000").Clear
  
      For Each qt In ActiveSheet.QueryTables
          qt.Delete
      Next qt
  
      With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A1"), Sql:=sqlstringFirma)
          .BackgroundQuery = False
          .RefreshStyle = xlOverwriteCells
          .Refresh '"General ODBC error" hereeee
      End With
  
      ActiveWorkbook.Sheets("Person").Select
      ActiveSheet.Range("A1:T2000").Clear
  
      For Each qt In ActiveSheet.QueryTables
          qt.Delete
      Next qt
  
      With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A1"), Sql:=sqlstringPerson)
          .BackgroundQuery = False
          .RefreshStyle = xlOverwriteCells
          .Refresh 'And hereee again
      End With
  
  
      Call Replace
      ActiveWorkbook.Sheets("Firma").Select
  
  End Sub
  </code></pre>
  
  <p>I did use .Select twice here and I know I should change it.</p>
  
  <p>I am working in Excel 2011 on a Mac so be aware that not everything that works on windows will work.</p>
  
  <p><strong>* EDIT *</strong></p>
  
  <p>First of all: Even if I have all the object libraries activated, this still doesn't work.</p>
  
  <p>Secondly, I just realized some things as I opened the Object Browser:</p>
  
  <ol>
  <li><p>"ODBCConnection" is a declared class ("Class ODBCConnection Member of Excel"). But when I click on Excel in the Object-Browser "ODBCConnection" is nowhere to be found. If I enter the code "Excel.ODBCConnection.Refresh" it throws the error "Method or Data Member not found" highlighting only the word "ODBCConnection". Same error is shown when I use only ODBCConnection.Refresh (Refresh being a method of ODBCConnection according to the Object Browser).</p></li>
  <li><p>I have exactly the same problem with "QueryTable(1).Refresh", which is throwing the error: "Variable not defined" even though it's listed and declared in the object-browser ("Class QueryTable Member of Excel").</p></li>
  </ol>
  
  <p>I believe I would get these kind of errors for all the things that are connected to this. </p>
  
  <p><strong><em>EDIT</em></strong></p>
  
  <p>This throws the same "General ODBC error" on the line ActiveWorkbook.RefreshAll:</p>
  
  <pre><code>Dim strConn As String
  Dim strLoginData As String
  Dim QT As QueryTable
  
  Dim strFirmSQL As String
  Dim strPersSQL As String
  
  strConn = "ODBC;DSN=KundeDB;" &amp; strLoginData
  strLoginData = "Uid=*myUid*;Pwd=*myPwd*"
  
  strFirmSQL = "Select * From gi_kunden.tbl_firma"
  strPersSQL = "Select * From gi_kunden.tbl_person"
  
  Dim WSFirm As Worksheet
  Set WSFirm = ActiveWorkbook.Sheets("Firma")
  
  WSFirm.Range("A1:T1000").Clear
  
  For Each QT In WSFirm.QueryTables
      QT.Delete
  Next QT
  
  With WSFirm.QueryTables.Add(strConn, WSFirm.Range("A1"), strFirmSQL)
      .SaveData = True
      .BackgroundQuery = True
      '.Refresh
  End With
  
  
  Dim WSPers As Worksheet
  Set WSPers = ActiveWorkbook.Sheets("Person")
  
  For Each QT In WSPers.QueryTables
      QT.Delete
  Next QT
  
  With WSPers.QueryTables.Add(strConn, WSPers.Range("A1"), strPersSQL)
      .SaveData = True
      .BackgroundQuery = True
      '.Refresh
  End With
  
  ActiveWorkbook.RefreshAll 'FAILS here
  
  Call Replace
  
  WSFirm.Activate
  </code></pre>